summaryrefslogtreecommitdiffstats
path: root/bank-eiffel
diff options
context:
space:
mode:
Diffstat (limited to 'bank-eiffel')
-rw-r--r--bank-eiffel/account.e3
-rw-r--r--bank-eiffel/tests/test_account.e139
-rw-r--r--bank-eiffel/tests/test_person.e24
3 files changed, 133 insertions, 33 deletions
diff --git a/bank-eiffel/account.e b/bank-eiffel/account.e
index 1fc62fb..7c127ec 100644
--- a/bank-eiffel/account.e
+++ b/bank-eiffel/account.e
@@ -105,7 +105,8 @@ feature -- Basic operations
105 105
106 remove_authorized_signer (an_authorized_signer: PERSON) 106 remove_authorized_signer (an_authorized_signer: PERSON)
107 require 107 require
108 authorized_signers_never_empty: get_authorized_signers.count >= 2 108 authorized_signers_never_empty: (get_authorized_signers.has (an_authorized_signer)
109 and get_authorized_signers.count >= 2) or True
109 do 110 do
110 if authorized_signers.has (an_authorized_signer) then 111 if authorized_signers.has (an_authorized_signer) then
111 authorized_signers.prune (an_authorized_signer) 112 authorized_signers.prune (an_authorized_signer)
diff --git a/bank-eiffel/tests/test_account.e b/bank-eiffel/tests/test_account.e
index 4430ab0..212ad6a 100644
--- a/bank-eiffel/tests/test_account.e
+++ b/bank-eiffel/tests/test_account.e
@@ -57,6 +57,97 @@ feature -- Test routines
57 account1.transfer_minamount := 10.0 57 account1.transfer_minamount := 10.0
58 end 58 end
59 59
60 ACCOUNT_CHECK_RANGES
61 local
62 person: PERSON
63 account: ACCOUNT
64 retry_count: INTEGER
65 do
66 create person.make("PERSON", "PERSON")
67 create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
68
69 inspect retry_count
70 when 0 then
71 account.interest_deposit := 0.0
72 assert("ACCOUNT_CHECK_RANGES_INTEREST_DEPOSIT_MIN", False)
73 when 1 then
74 account.interest_deposit := 0.023
75 assert("ACCOUNT_CHECK_RANGES_INTEREST_DEPOSIT_MAX", False)
76 when 2 then
77 account.interest_debit := 0.0
78 assert("ACCOUNT_CHECK_RANGES_INTEREST_DEBIT_MIN", False)
79 when 3 then
80 account.interest_debit := 0.03
81 assert("ACCOUNT_CHECK_RANGES_INTEREST_DEBIT_MAX", False)
82 when 4 then
83 account.creditline := -101.0
84 assert("ACCOUNT_CHECK_RANGES_CREDITLINE_MIN", False)
85 when 5 then
86 account.creditline := -49.0
87 assert("ACCOUNT_CHECK_RANGES_CREDITLINE_MAX", False)
88 when 6 then
89 account.transfer_minamount := -1.0
90 assert("ACCOUNT_CHECK_RANGES_TRANSFER_MINAMOUNT_POSITIVE", False)
91 else
92 end
93 rescue
94 if not (create {EXCEPTIONS}).is_developer_exception then
95 retry_count := retry_count + 1
96 retry
97 end
98 end
99
100 ACCOUNT_CHECK_OPERATIONS
101 local
102 person1: PERSON
103 account1: ACCOUNT
104 person2: PERSON
105 account2: ACCOUNT
106 retry_count: INTEGER
107 i: INTEGER
108 do
109 create person1.make("PERSON1", "PERSON1")
110 create person2.make("PERSON2", "PERSON2")
111 create account1.make(person1, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
112 create account2.make(person2, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
113
114 inspect retry_count
115 when 0 then
116 account1.deposit (10.0, person2)
117 assert("ACCOUNT_CHECK_OPERATIONS_DEPOSIT_OTHER", False)
118 when 1 then
119 account1.withdraw (10.0, person2)
120 assert("ACCOUNT_CHECK_OPERATIONS_WITHDRAW_OTHER", False)
121 when 2 then
122 account1.transfer (10.0, person2, account2, person2)
123 assert("ACCOUNT_CHECK_OPERATIONS_TRANSFER_OTHER_1", False)
124 when 3 then
125 account1.transfer (10.0, person1, account2, person1)
126 assert("ACCOUNT_CHECK_OPERATIONS_TRANSFER_OTHER_2", False)
127 when 4 then
128 account1.withdraw (51.0, person1)
129 assert("ACCOUNT_CHECK_OPERATIONS_WITHDRAW_OVER_CREDIT", False)
130 when 5 then
131 account1.deposit (1.0, person1)
132 assert("ACCOUNT_CHECK_OPERATIONS_DEPOSIT_BELOW_MINAMOUNT", False)
133 when 6 then
134 account1.withdraw (1.0, person1)
135 assert("ACCOUNT_CHECK_OPERATIONS_WITHDRAW_BELOW_MINAMOUNT", False)
136 when 7 then
137 account1.transfer (1.0, person1, account2, person2)
138 assert("ACCOUNT_CHECK_OPERATIONS_TRANSFER_BELOW_MINAMOUNT", False)
139 when 8 then
140 account1.remove_authorized_signer (person1)
141 assert("ACCOUNT_CHECK_OPERATIONS_REMOVE_AUTHORIZED_SIGNER_EMPTY", False)
142 else
143 end
144 rescue
145 if retry_count /= 9 and not (create {EXCEPTIONS}).is_developer_exception then
146 retry_count := retry_count + 1
147 retry
148 end
149 end
150
60 CREATE_STUDENTACCOUNT 151 CREATE_STUDENTACCOUNT
61 local 152 local
62 student: STUDENT 153 student: STUDENT
@@ -68,7 +159,7 @@ feature -- Test routines
68 assert("CREATE_STUDENTACCOUNT_MINAMOUNT", account.transfer_minamount = 1.0) 159 assert("CREATE_STUDENTACCOUNT_MINAMOUNT", account.transfer_minamount = 1.0)
69 end 160 end
70 161
71 CREATE_STUDENTACCOUNT_ONLY_STUDENTS 162 STUDENTACCOUNT_ONLY_STUDENTS
72 local 163 local
73 account: STUDENTACCOUNT 164 account: STUDENTACCOUNT
74 student: STUDENT 165 student: STUDENT
@@ -80,24 +171,26 @@ feature -- Test routines
80 create person.make("PERSON", "PERSON") 171 create person.make("PERSON", "PERSON")
81 create retiree.make("RETIREE", "RETIREE") 172 create retiree.make("RETIREE", "RETIREE")
82 173
83 if retry_count = 0 then 174 inspect retry_count
175 when 0 then
84 create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 176 create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
85 assert("CREATE_STUDENTACCOUNT_ONLY_STUDENTS_1", False) 177 assert("STUDENTACCOUNT_ONLY_STUDENTS_1", False)
86 elseif retry_count = 1 then 178 when 1 then
87 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 179 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
88 assert("CREATE_STUDENTACCOUNT_ONLY_STUDENTS_2", False) 180 assert("STUDENTACCOUNT_ONLY_STUDENTS_2", False)
89 elseif retry_count = 2 then 181 when 2 then
90 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 182 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
91 account.add_authorized_signer (create {STUDENT}.make("STUDENT2", "STUDENT2")) 183 account.add_authorized_signer (create {STUDENT}.make("STUDENT2", "STUDENT2"))
92 assert("CREATE_STUDENTACCOUNT_ONE_STUDENT_ONLY_1", False) 184 assert("STUDENTACCOUNT_ONE_STUDENT_ONLY_1", False)
93 elseif retry_count = 3 then 185 when 3 then
94 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 186 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
95 account.add_authorized_signer (person) 187 account.add_authorized_signer (person)
96 assert("CREATE_STUDENTACCOUNT_ONE_STUDENT_ONLY_2", False) 188 assert("STUDENTACCOUNT_ONE_STUDENT_ONLY_2", False)
97 elseif retry_count = 4 then 189 when 4 then
98 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 190 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
99 account.add_authorized_signer (retiree) 191 account.add_authorized_signer (retiree)
100 assert("CREATE_STUDENTACCOUNT_ONE_STUDENT_ONLY_3", False) 192 assert("STUDENTACCOUNT_ONE_STUDENT_ONLY_3", False)
193 else
101 end 194 end
102 rescue 195 rescue
103 if not (create {EXCEPTIONS}).is_developer_exception then 196 if not (create {EXCEPTIONS}).is_developer_exception then
@@ -118,7 +211,7 @@ feature -- Test routines
118 end 211 end
119 212
120 213
121 CREATE_RETIREEACCOUNT_ONLY_RETIREES 214 RETIREEACCOUNT_ONLY_RETIREES
122 local 215 local
123 account: RETIREEACCOUNT 216 account: RETIREEACCOUNT
124 retiree: RETIREE 217 retiree: RETIREE
@@ -130,24 +223,26 @@ feature -- Test routines
130 create person.make("PERSON", "PERSON") 223 create person.make("PERSON", "PERSON")
131 create student.make("STUDENT", "STUDENT") 224 create student.make("STUDENT", "STUDENT")
132 225
133 if retry_count = 0 then 226 inspect retry_count
227 when 0 then
134 create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 228 create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
135 assert("CREATE_RETIREEACCOUNT_ONLY_RETIREES_1", False) 229 assert("RETIREEACCOUNT_ONLY_RETIREES_1", False)
136 elseif retry_count = 1 then 230 when 1 then
137 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 231 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
138 assert("CREATE_RETIREEACCOUNT_ONLY_RETIREES_2", False) 232 assert("RETIREEACCOUNT_ONLY_RETIREES_2", False)
139 elseif retry_count = 2 then 233 when 2 then
140 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 234 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
141 account.add_authorized_signer (create {RETIREE}.make("RETIREE2", "RETIREE2")) 235 account.add_authorized_signer (create {RETIREE}.make("RETIREE2", "RETIREE2"))
142 assert("CREATE_RETIREEACCOUNT_ONE_RETIREE_ONLY_1", False) 236 assert("RETIREEACCOUNT_ONE_RETIREE_ONLY_1", False)
143 elseif retry_count = 3 then 237 when 3 then
144 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 238 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
145 account.add_authorized_signer (person) 239 account.add_authorized_signer (person)
146 assert("CREATE_RETIREEACCOUNT_ONE_RETIREE_ONLY_2", False) 240 assert("RETIREEACCOUNT_ONE_RETIREE_ONLY_2", False)
147 elseif retry_count = 4 then 241 when 4 then
148 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 242 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
149 account.add_authorized_signer (student) 243 account.add_authorized_signer (student)
150 assert("CREATE_RETIREEACCOUNT_ONE_RETIREE_ONLY_3", False) 244 assert("RETIREEACCOUNT_ONE_RETIREE_ONLY_3", False)
245 else
151 end 246 end
152 rescue 247 rescue
153 if not (create {EXCEPTIONS}).is_developer_exception then 248 if not (create {EXCEPTIONS}).is_developer_exception then
diff --git a/bank-eiffel/tests/test_person.e b/bank-eiffel/tests/test_person.e
index f42767c..01e9a50 100644
--- a/bank-eiffel/tests/test_person.e
+++ b/bank-eiffel/tests/test_person.e
@@ -26,18 +26,20 @@ feature -- Test routines
26 assert("CREATE_EDIT_PERSON_RETIREE", attached {PERSON} student) 26 assert("CREATE_EDIT_PERSON_RETIREE", attached {PERSON} student)
27 end 27 end
28 28
29 CREATE_EDIT_PERSON_EMPTY_SURNAME 29 PERSON_EMPTY_SURNAME
30 local 30 local
31 person: PERSON 31 person: PERSON
32 retry_count: INTEGER 32 retry_count: INTEGER
33 do 33 do
34 if retry_count = 0 then 34 inspect retry_count
35 when 0 then
35 create person.make("", "SOME_FIRSTNAME") 36 create person.make("", "SOME_FIRSTNAME")
36 assert("CREATE_EDIT_PERSON_EMPTY_SURNAME_1", False) 37 assert("PERSON_EMPTY_SURNAME_1", False)
37 elseif retry_count = 1 then 38 when 1 then
38 create person.make("SOME_SURNAME", "SOME_FIRSTNAME") 39 create person.make("SOME_SURNAME", "SOME_FIRSTNAME")
39 person.surname := "" 40 person.surname := ""
40 assert("CREATE_EDIT_PERSON_EMPTY_SURNAME_3", False) 41 assert("PERSON_EMPTY_SURNAME_3", False)
42 else
41 end 43 end
42 rescue 44 rescue
43 if not (create {EXCEPTIONS}).is_developer_exception then 45 if not (create {EXCEPTIONS}).is_developer_exception then
@@ -46,18 +48,20 @@ feature -- Test routines
46 end 48 end
47 end 49 end
48 50
49 CREATE_EDIT_PERSON_EMPTY_FIRSTNAME 51 PERSON_EMPTY_FIRSTNAME
50 local 52 local
51 person: PERSON 53 person: PERSON
52 retry_count: INTEGER 54 retry_count: INTEGER
53 do 55 do
54 if retry_count = 0 then 56 inspect retry_count
57 when 0 then
55 create person.make("SOME_SURNAME", "") 58 create person.make("SOME_SURNAME", "")
56 assert("CREATE_EDIT_PERSON_EMPTY_FIRSTNAME_1", False) 59 assert("PERSON_EMPTY_FIRSTNAME_1", False)
57 elseif retry_count = 1 then 60 when 1 then
58 create person.make("SOME_SURNAME", "SOME_FIRSTNAME") 61 create person.make("SOME_SURNAME", "SOME_FIRSTNAME")
59 person.firstname := "" 62 person.firstname := ""
60 assert("CREATE_EDIT_PERSON_EMPTY_FIRSTNAME_3", False) 63 assert("PERSON_EMPTY_FIRSTNAME_3", False)
64 else
61 end 65 end
62 rescue 66 rescue
63 if not (create {EXCEPTIONS}).is_developer_exception then 67 if not (create {EXCEPTIONS}).is_developer_exception then