summaryrefslogtreecommitdiffstats
path: root/bank-eiffel/tests/test_account.e
diff options
context:
space:
mode:
Diffstat (limited to 'bank-eiffel/tests/test_account.e')
-rw-r--r--bank-eiffel/tests/test_account.e249
1 files changed, 234 insertions, 15 deletions
diff --git a/bank-eiffel/tests/test_account.e b/bank-eiffel/tests/test_account.e
index a460023..0b6ac46 100644
--- a/bank-eiffel/tests/test_account.e
+++ b/bank-eiffel/tests/test_account.e
@@ -1,12 +1,3 @@
1note
2 description: "[
3 Eiffel tests that can be executed by testing tool.
4 ]"
5 author: "EiffelStudio test wizard"
6 date: "$Date$"
7 revision: "$Revision$"
8 testing: "type/manual"
9
10class 1class
11 TEST_ACCOUNT 2 TEST_ACCOUNT
12 3
@@ -19,15 +10,243 @@ feature -- Test routines
19 local 10 local
20 person1: PERSON 11 person1: PERSON
21 person2: PERSON 12 person2: PERSON
13 person3: PERSON
14 account1: ACCOUNT
15 account2: ACCOUNT
16 do
17 create person1.make ("PERSON1", "PERSON1")
18 create person2.make ("PERSON2", "PERSON2")
19 create person3.make ("PERSON3", "PERSON3")
20
21 create account1.make (person1, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
22 assert("CREATE_EDIT_ACCOUNT_MINAMOUNT", account1.transfer_minamount = 2.0)
23
24 assert("CREATE_EDIT_ACCOUNT_SIGNER_1", account1.get_authorized_signers.count = 1)
25 account1.add_authorized_signer (person2)
26 account1.add_authorized_signer (person2)
27 account1.add_authorized_signer (person3)
28 account1.remove_authorized_signer (person3)
29 assert("CREATE_EDIT_ACCOUNT_SIGNER_2", account1.get_authorized_signers.count = 2)
30
31 assert("CREATE_EDIT_ACCOUNT_BALANCE_1", account1.balance = 0.0)
32 account1.deposit (50.0, person1)
33 account1.deposit (50.0, person2)
34 -- balance = 100.0
35 account1.advance
36 -- balance = 100.0 + 1% deposit
37 account1.withdraw (100.0 + 100.0 * 0.01 + 50.0, person1)
38 -- balance = -50.0
39 account1.creditline := -100.0
40 account1.withdraw (50.0, person1)
41 -- balance = -100.0
42 account1.advance
43 -- balance = -100.0 + 2% debit
44 assert("CREATE_EDIT_ACCOUNT_BALANCE_2", account1.balance = -102.0)
45
46 create account2.make(person3, 0.01, 0.02, -50, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
47 account2.deposit (102.0, person3)
48 account2.transfer (102.0, person3, account1, person1)
49 assert("CREATE_EDIT_ACCOUNT_BALANCE_3", account1.balance = 0.0 and account2.balance = 0.0)
50
51 account1.interest_deposit := 0.01
52 account1.interest_deposit := 0.022
53 account1.interest_debit := 0.01
54 account1.interest_debit := 0.02
55 account1.creditline := -100.0
56 account1.creditline := -50.0
57 account1.transfer_minamount := 10.0
58 end
59
60 ACCOUNT_CHECK_RANGES
61 local
62 person: PERSON
22 account: ACCOUNT 63 account: ACCOUNT
64 retry_count: INTEGER
23 do 65 do
24 create person1.make ("SOME_SURNAME_1", "SOME_FIRSTNAME_1") 66 create person.make("PERSON", "PERSON")
25 create person2.make ("SOME_SURNAME_2", "SOME_FIRSTNAME_2") 67 create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
26 create account.make (person1) 68
27 account.add_authorized_signer (person2) 69 inspect retry_count
28 --assert ("not_implemented", False) 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
29 end 98 end
30 99
31end 100 ACCOUNT_CHECK_OPERATIONS
101 local
102 person1: PERSON
103 account1: ACCOUNT
104 person2: PERSON
105 account2: ACCOUNT
106 retry_count: INTEGER
107 do
108 create person1.make("PERSON1", "PERSON1")
109 create person2.make("PERSON2", "PERSON2")
110 create account1.make(person1, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
111 create account2.make(person2, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
112
113 inspect retry_count
114 when 0 then
115 account1.deposit (10.0, person2)
116 assert("ACCOUNT_CHECK_OPERATIONS_DEPOSIT_OTHER", False)
117 when 1 then
118 account1.withdraw (10.0, person2)
119 assert("ACCOUNT_CHECK_OPERATIONS_WITHDRAW_OTHER", False)
120 when 2 then
121 account1.transfer (10.0, person2, account2, person2)
122 assert("ACCOUNT_CHECK_OPERATIONS_TRANSFER_OTHER_1", False)
123 when 3 then
124 account1.transfer (10.0, person1, account2, person1)
125 assert("ACCOUNT_CHECK_OPERATIONS_TRANSFER_OTHER_2", False)
126 when 4 then
127 account1.withdraw (51.0, person1)
128 assert("ACCOUNT_CHECK_OPERATIONS_WITHDRAW_OVER_CREDIT", False)
129 when 5 then
130 account1.deposit (1.0, person1)
131 assert("ACCOUNT_CHECK_OPERATIONS_DEPOSIT_BELOW_MINAMOUNT", False)
132 when 6 then
133 account1.withdraw (1.0, person1)
134 assert("ACCOUNT_CHECK_OPERATIONS_WITHDRAW_BELOW_MINAMOUNT", False)
135 when 7 then
136 account1.transfer (1.0, person1, account2, person2)
137 assert("ACCOUNT_CHECK_OPERATIONS_TRANSFER_BELOW_MINAMOUNT", False)
138 when 8 then
139 account1.remove_authorized_signer (person1)
140 assert("ACCOUNT_CHECK_OPERATIONS_REMOVE_AUTHORIZED_SIGNER_EMPTY", False)
141 else
142 end
143 rescue
144 if retry_count /= 9 and not (create {EXCEPTIONS}).is_developer_exception then
145 retry_count := retry_count + 1
146 retry
147 end
148 end
32 149
150 CREATE_STUDENTACCOUNT
151 local
152 student: STUDENT
153 account: STUDENTACCOUNT
154 do
155 create student.make("STUDENT", "STUDENT")
156 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
157 assert("CREATE_STUDENTACCOUNT", attached {ACCOUNT} account)
158 assert("CREATE_STUDENTACCOUNT_MINAMOUNT", account.transfer_minamount = 1.0)
159 end
160
161 STUDENTACCOUNT_ONLY_STUDENTS
162 local
163 account: STUDENTACCOUNT
164 student: STUDENT
165 person: PERSON
166 retiree: RETIREE
167 retry_count: INTEGER
168 do
169 create student.make("STUDENT", "STUDENT")
170 create person.make("PERSON", "PERSON")
171 create retiree.make("RETIREE", "RETIREE")
172
173 inspect retry_count
174 when 0 then
175 create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
176 assert("STUDENTACCOUNT_ONLY_STUDENTS_1", False)
177 when 1 then
178 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
179 assert("STUDENTACCOUNT_ONLY_STUDENTS_2", False)
180 when 2 then
181 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
182 account.add_authorized_signer (create {STUDENT}.make("STUDENT2", "STUDENT2"))
183 assert("STUDENTACCOUNT_ONE_STUDENT_ONLY_1", False)
184 when 3 then
185 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
186 account.add_authorized_signer (person)
187 assert("STUDENTACCOUNT_ONE_STUDENT_ONLY_2", False)
188 when 4 then
189 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
190 account.add_authorized_signer (retiree)
191 assert("STUDENTACCOUNT_ONE_STUDENT_ONLY_3", False)
192 else
193 end
194 rescue
195 if not (create {EXCEPTIONS}).is_developer_exception then
196 retry_count := retry_count + 1
197 retry
198 end
199 end
200
201 CREATE_RETIREEACCOUNT
202 local
203 retiree: RETIREE
204 account: RETIREEACCOUNT
205 do
206 create retiree.make("RETIREE", "RETIREE")
207 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
208 assert("CREATE_RETIREEACCOUNT", attached {ACCOUNT} account)
209 assert("CREATE_RETIREEACCOUNT_MINAMOUNT", account.transfer_minamount = 1.0)
210 end
33 211
212
213 RETIREEACCOUNT_ONLY_RETIREES
214 local
215 account: RETIREEACCOUNT
216 retiree: RETIREE
217 person: PERSON
218 student: STUDENT
219 retry_count: INTEGER
220 do
221 create retiree.make("RETIREE", "RETIREE")
222 create person.make("PERSON", "PERSON")
223 create student.make("STUDENT", "STUDENT")
224
225 inspect retry_count
226 when 0 then
227 create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
228 assert("RETIREEACCOUNT_ONLY_RETIREES_1", False)
229 when 1 then
230 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
231 assert("RETIREEACCOUNT_ONLY_RETIREES_2", False)
232 when 2 then
233 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
234 account.add_authorized_signer (create {RETIREE}.make("RETIREE2", "RETIREE2"))
235 assert("RETIREEACCOUNT_ONE_RETIREE_ONLY_1", False)
236 when 3 then
237 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
238 account.add_authorized_signer (person)
239 assert("RETIREEACCOUNT_ONE_RETIREE_ONLY_2", False)
240 when 4 then
241 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
242 account.add_authorized_signer (student)
243 assert("RETIREEACCOUNT_ONE_RETIREE_ONLY_3", False)
244 else
245 end
246 rescue
247 if not (create {EXCEPTIONS}).is_developer_exception then
248 retry_count := retry_count + 1
249 retry
250 end
251 end
252end