summaryrefslogtreecommitdiffstats
path: root/bank-eiffel
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2011-05-23 20:37:54 +0200
committermanuel <manuel@mausz.at>2011-05-23 20:37:54 +0200
commit1daf62f05c19e6f96d16d3688055dfd20d89d2b8 (patch)
tree4e79c5894ee9f5c1d350565e6aae2f9dbd31deaa /bank-eiffel
parente03195a9325d2671208efc45f4a4d083664eafe2 (diff)
downloadfoop-1daf62f05c19e6f96d16d3688055dfd20d89d2b8.tar.gz
foop-1daf62f05c19e6f96d16d3688055dfd20d89d2b8.tar.bz2
foop-1daf62f05c19e6f96d16d3688055dfd20d89d2b8.zip
- add tests
- remove notes - fix minamount for subaccounts
Diffstat (limited to 'bank-eiffel')
-rw-r--r--bank-eiffel/account.e16
-rw-r--r--bank-eiffel/application.e5
-rw-r--r--bank-eiffel/bank.e6
-rw-r--r--bank-eiffel/person.e6
-rw-r--r--bank-eiffel/retiree.e8
-rw-r--r--bank-eiffel/retireeaccount.e18
-rw-r--r--bank-eiffel/student.e6
-rw-r--r--bank-eiffel/studentaccount.e16
-rw-r--r--bank-eiffel/tests/test_account.e111
-rw-r--r--bank-eiffel/tests/test_person.e37
10 files changed, 131 insertions, 98 deletions
diff --git a/bank-eiffel/account.e b/bank-eiffel/account.e
index d0a3fc4..1fc62fb 100644
--- a/bank-eiffel/account.e
+++ b/bank-eiffel/account.e
@@ -1,9 +1,3 @@
1note
2 description: "Summary description for {ACCOUNT}."
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7class 1class
8 ACCOUNT 2 ACCOUNT
9 3
@@ -57,14 +51,15 @@ feature {NONE} -- Initialization
57 do 51 do
58 create authorized_signers.make(1) 52 create authorized_signers.make(1)
59 add_authorized_signer (an_authorized_signer) 53 add_authorized_signer (an_authorized_signer)
60 transfer_minamount := 2.0
61 balance := 0.0
62 creditline := a_credit_line 54 creditline := a_credit_line
63 interest_debit := an_interest_debit 55 interest_debit := an_interest_debit
64 interest_deposit := an_interest_deposit 56 interest_deposit := an_interest_deposit
65 interest_deposit_range := an_interest_deposit_range 57 interest_deposit_range := an_interest_deposit_range
66 interest_debit_range := an_interest_debit_range 58 interest_debit_range := an_interest_debit_range
67 creditline_range := a_credit_line_range 59 creditline_range := a_credit_line_range
60
61 set_default_transfer_minamount
62 balance := 0.0
68 end 63 end
69 64
70feature -- Basic operations 65feature -- Basic operations
@@ -146,6 +141,11 @@ feature {NONE} -- Implementation
146 transfer_minamount_assigned: transfer_minamount = a_transfer_minamount 141 transfer_minamount_assigned: transfer_minamount = a_transfer_minamount
147 end 142 end
148 143
144 set_default_transfer_minamount
145 do
146 set_transfer_minamount (2.0)
147 end
148
149 set_creditline (a_creditline: like creditline) 149 set_creditline (a_creditline: like creditline)
150 require 150 require
151 a_creditline_within_bounds: a_creditline >= creditline_range.min 151 a_creditline_within_bounds: a_creditline >= creditline_range.min
diff --git a/bank-eiffel/application.e b/bank-eiffel/application.e
index c880bf9..55b02d9 100644
--- a/bank-eiffel/application.e
+++ b/bank-eiffel/application.e
@@ -1,8 +1,3 @@
1note
2 description : "bank application root class"
3 date : "$Date$"
4 revision : "$Revision$"
5
6class 1class
7 APPLICATION 2 APPLICATION
8 3
diff --git a/bank-eiffel/bank.e b/bank-eiffel/bank.e
index 7c30afb..bad3bda 100644
--- a/bank-eiffel/bank.e
+++ b/bank-eiffel/bank.e
@@ -1,9 +1,3 @@
1note
2 description: "Summary description for {BANK}."
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7class 1class
8 BANK 2 BANK
9 3
diff --git a/bank-eiffel/person.e b/bank-eiffel/person.e
index 9a2b281..ffaab72 100644
--- a/bank-eiffel/person.e
+++ b/bank-eiffel/person.e
@@ -1,9 +1,3 @@
1note
2 description: "Summary description for {PERSON}."
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7class 1class
8 PERSON 2 PERSON
9 3
diff --git a/bank-eiffel/retiree.e b/bank-eiffel/retiree.e
index 7f24d89..e8a2edd 100644
--- a/bank-eiffel/retiree.e
+++ b/bank-eiffel/retiree.e
@@ -1,9 +1,3 @@
1note
2 description: "Summary description for {RETIREE}."
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7class 1class
8 RETIREE 2 RETIREE
9 3
@@ -12,5 +6,5 @@ inherit
12 6
13create 7create
14 make 8 make
15 9
16end 10end
diff --git a/bank-eiffel/retireeaccount.e b/bank-eiffel/retireeaccount.e
index cf9bc91..3db0cd4 100644
--- a/bank-eiffel/retireeaccount.e
+++ b/bank-eiffel/retireeaccount.e
@@ -1,18 +1,22 @@
1note
2 description: "Summary description for {RETIREEACCOUNT}."
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7class 1class
8 RETIREEACCOUNT 2 RETIREEACCOUNT
9 3
10inherit 4inherit
11 ACCOUNT 5 ACCOUNT
12 6 redefine
7 set_default_transfer_minamount
8 end
9
13create 10create
14 make 11 make
15 12
13feature {NONE} -- Implementation
14
15 set_default_transfer_minamount
16 do
17 set_transfer_minamount (1.0)
18 end
19
16invariant 20invariant
17 authorized_signers_only_one: authorized_signers.count = 1 21 authorized_signers_only_one: authorized_signers.count = 1
18 authorized_signers_attached: authorized_signers.linear_representation /= Void 22 authorized_signers_attached: authorized_signers.linear_representation /= Void
diff --git a/bank-eiffel/student.e b/bank-eiffel/student.e
index f910fa7..0c3863a 100644
--- a/bank-eiffel/student.e
+++ b/bank-eiffel/student.e
@@ -1,9 +1,3 @@
1note
2 description: "Summary description for {STUDENT}."
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7class 1class
8 STUDENT 2 STUDENT
9 3
diff --git a/bank-eiffel/studentaccount.e b/bank-eiffel/studentaccount.e
index d1ccaef..04a9e31 100644
--- a/bank-eiffel/studentaccount.e
+++ b/bank-eiffel/studentaccount.e
@@ -1,18 +1,22 @@
1note
2 description: "Summary description for {STUDENTACCOUNT}."
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7class 1class
8 STUDENTACCOUNT 2 STUDENTACCOUNT
9 3
10inherit 4inherit
11 ACCOUNT 5 ACCOUNT
6 redefine
7 set_default_transfer_minamount
8 end
12 9
13create 10create
14 make 11 make
15 12
13feature {NONE} -- Implementation
14
15 set_default_transfer_minamount
16 do
17 set_transfer_minamount (1.0)
18 end
19
16invariant 20invariant
17 authorized_signers_only_one: authorized_signers.count = 1 21 authorized_signers_only_one: authorized_signers.count = 1
18 authorized_signers_attached: authorized_signers.linear_representation /= Void 22 authorized_signers_attached: authorized_signers.linear_representation /= Void
diff --git a/bank-eiffel/tests/test_account.e b/bank-eiffel/tests/test_account.e
index e1ca892..4430ab0 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
@@ -23,11 +14,13 @@ feature -- Test routines
23 account1: ACCOUNT 14 account1: ACCOUNT
24 account2: ACCOUNT 15 account2: ACCOUNT
25 do 16 do
26 create person1.make ("SOME_SURNAME_1", "SOME_FIRSTNAME_1") 17 create person1.make ("PERSON1", "PERSON1")
27 create person2.make ("SOME_SURNAME_2", "SOME_FIRSTNAME_2") 18 create person2.make ("PERSON2", "PERSON2")
28 create person3.make ("SOME_SURNAME_3", "SOME_FIRSTNAME_3") 19 create person3.make ("PERSON3", "PERSON3")
29 20
30 create account1.make (person1, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 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
31 assert("CREATE_EDIT_ACCOUNT_SIGNER_1", account1.get_authorized_signers.count = 1) 24 assert("CREATE_EDIT_ACCOUNT_SIGNER_1", account1.get_authorized_signers.count = 1)
32 account1.add_authorized_signer (person2) 25 account1.add_authorized_signer (person2)
33 account1.add_authorized_signer (person2) 26 account1.add_authorized_signer (person2)
@@ -66,20 +59,100 @@ feature -- Test routines
66 59
67 CREATE_STUDENTACCOUNT 60 CREATE_STUDENTACCOUNT
68 local 61 local
69 person: STUDENT 62 student: STUDENT
63 account: STUDENTACCOUNT
64 do
65 create student.make("STUDENT", "STUDENT")
66 create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
67 assert("CREATE_STUDENTACCOUNT", attached {ACCOUNT} account)
68 assert("CREATE_STUDENTACCOUNT_MINAMOUNT", account.transfer_minamount = 1.0)
69 end
70
71 CREATE_STUDENTACCOUNT_ONLY_STUDENTS
72 local
70 account: STUDENTACCOUNT 73 account: STUDENTACCOUNT
74 student: STUDENT
75 person: PERSON
76 retiree: RETIREE
77 retry_count: INTEGER
71 do 78 do
72 create person.make("SOME_SURNAME", "SOME_FIRSTNAME") 79 create student.make("STUDENT", "STUDENT")
73 create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 80 create person.make("PERSON", "PERSON")
81 create retiree.make("RETIREE", "RETIREE")
82
83 if retry_count = 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])
85 assert("CREATE_STUDENTACCOUNT_ONLY_STUDENTS_1", False)
86 elseif retry_count = 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])
88 assert("CREATE_STUDENTACCOUNT_ONLY_STUDENTS_2", False)
89 elseif retry_count = 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])
91 account.add_authorized_signer (create {STUDENT}.make("STUDENT2", "STUDENT2"))
92 assert("CREATE_STUDENTACCOUNT_ONE_STUDENT_ONLY_1", False)
93 elseif retry_count = 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])
95 account.add_authorized_signer (person)
96 assert("CREATE_STUDENTACCOUNT_ONE_STUDENT_ONLY_2", False)
97 elseif retry_count = 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])
99 account.add_authorized_signer (retiree)
100 assert("CREATE_STUDENTACCOUNT_ONE_STUDENT_ONLY_3", False)
101 end
102 rescue
103 if not (create {EXCEPTIONS}).is_developer_exception then
104 retry_count := retry_count + 1
105 retry
106 end
74 end 107 end
75 108
76 CREATE_RETIREEACCOUNT 109 CREATE_RETIREEACCOUNT
77 local 110 local
78 person: RETIREE 111 retiree: RETIREE
79 account: RETIREEACCOUNT 112 account: RETIREEACCOUNT
80 do 113 do
81 create person.make("SOME_SURNAME", "SOME_FIRSTNAME") 114 create retiree.make("RETIREE", "RETIREE")
82 create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) 115 create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0])
116 assert("CREATE_RETIREEACCOUNT", attached {ACCOUNT} account)
117 assert("CREATE_RETIREEACCOUNT_MINAMOUNT", account.transfer_minamount = 1.0)
83 end 118 end
84end
85 119
120
121 CREATE_RETIREEACCOUNT_ONLY_RETIREES
122 local
123 account: RETIREEACCOUNT
124 retiree: RETIREE
125 person: PERSON
126 student: STUDENT
127 retry_count: INTEGER
128 do
129 create retiree.make("RETIREE", "RETIREE")
130 create person.make("PERSON", "PERSON")
131 create student.make("STUDENT", "STUDENT")
132
133 if retry_count = 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])
135 assert("CREATE_RETIREEACCOUNT_ONLY_RETIREES_1", False)
136 elseif retry_count = 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])
138 assert("CREATE_RETIREEACCOUNT_ONLY_RETIREES_2", False)
139 elseif retry_count = 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])
141 account.add_authorized_signer (create {RETIREE}.make("RETIREE2", "RETIREE2"))
142 assert("CREATE_RETIREEACCOUNT_ONE_RETIREE_ONLY_1", False)
143 elseif retry_count = 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])
145 account.add_authorized_signer (person)
146 assert("CREATE_RETIREEACCOUNT_ONE_RETIREE_ONLY_2", False)
147 elseif retry_count = 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])
149 account.add_authorized_signer (student)
150 assert("CREATE_RETIREEACCOUNT_ONE_RETIREE_ONLY_3", False)
151 end
152 rescue
153 if not (create {EXCEPTIONS}).is_developer_exception then
154 retry_count := retry_count + 1
155 retry
156 end
157 end
158end
diff --git a/bank-eiffel/tests/test_person.e b/bank-eiffel/tests/test_person.e
index 67aea34..f42767c 100644
--- a/bank-eiffel/tests/test_person.e
+++ b/bank-eiffel/tests/test_person.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_PERSON 2 TEST_PERSON
12 3
@@ -14,10 +5,11 @@ inherit
14 EQA_TEST_SET 5 EQA_TEST_SET
15 6
16feature -- Test routines 7feature -- Test routines
17
18 CREATE_EDIT_PERSON 8 CREATE_EDIT_PERSON
19 local 9 local
20 person: PERSON 10 person: PERSON
11 student: STUDENT
12 retiree: RETIREE
21 do 13 do
22 create person.make("SOME_SURNAME_1", "SOME_FIRSTNAME_1") 14 create person.make("SOME_SURNAME_1", "SOME_FIRSTNAME_1")
23 assert("CREATE_EDIT_PERSON_FIRSTNAME_1", person.firstname.is_equal("SOME_FIRSTNAME_1")) 15 assert("CREATE_EDIT_PERSON_FIRSTNAME_1", person.firstname.is_equal("SOME_FIRSTNAME_1"))
@@ -27,31 +19,28 @@ feature -- Test routines
27 assert("CREATE_EDIT_PERSON_FIRSTNAME_2", person.firstname.is_equal("SOME_FIRSTNAME_2")) 19 assert("CREATE_EDIT_PERSON_FIRSTNAME_2", person.firstname.is_equal("SOME_FIRSTNAME_2"))
28 person.surname := "SOME_SURNAME_2" 20 person.surname := "SOME_SURNAME_2"
29 assert("CREATE_EDIT_PERSON_SURNAME_2", person.surname.is_equal("SOME_SURNAME_2")) 21 assert("CREATE_EDIT_PERSON_SURNAME_2", person.surname.is_equal("SOME_SURNAME_2"))
22
23 create student.make ("STUDENT_SURNAME", "STUDENT_FIRSTNAME")
24 assert("CREATE_EDIT_PERSON_STUDENT", attached {PERSON} student)
25 create retiree.make ("RETIREE_SURNAME", "RETIREE_FIRSTNAME")
26 assert("CREATE_EDIT_PERSON_RETIREE", attached {PERSON} student)
30 end 27 end
31 28
32 CREATE_EDIT_PERSON_EMPTY_SURNAME 29 CREATE_EDIT_PERSON_EMPTY_SURNAME
33 local 30 local
34 person: PERSON 31 person: PERSON
35 retry_count: INTEGER 32 retry_count: INTEGER
36 doretry: BOOLEAN
37 do 33 do
38 if retry_count = 0 then 34 if retry_count = 0 then
39 doretry := True
40 create person.make("", "SOME_FIRSTNAME") 35 create person.make("", "SOME_FIRSTNAME")
41 doretry := False
42 assert("CREATE_EDIT_PERSON_EMPTY_SURNAME_1", False) 36 assert("CREATE_EDIT_PERSON_EMPTY_SURNAME_1", False)
43 elseif retry_count = 1 then 37 elseif retry_count = 1 then
44 doretry := False
45 create person.make("SOME_SURNAME", "SOME_FIRSTNAME") 38 create person.make("SOME_SURNAME", "SOME_FIRSTNAME")
46 doretry := True
47 person.surname := "" 39 person.surname := ""
48 doretry := False
49 assert("CREATE_EDIT_PERSON_EMPTY_SURNAME_3", False) 40 assert("CREATE_EDIT_PERSON_EMPTY_SURNAME_3", False)
50 else
51 doretry := False
52 end 41 end
53 rescue 42 rescue
54 if doretry then 43 if not (create {EXCEPTIONS}).is_developer_exception then
55 retry_count := retry_count + 1 44 retry_count := retry_count + 1
56 retry 45 retry
57 end 46 end
@@ -61,25 +50,17 @@ feature -- Test routines
61 local 50 local
62 person: PERSON 51 person: PERSON
63 retry_count: INTEGER 52 retry_count: INTEGER
64 doretry: BOOLEAN
65 do 53 do
66 if retry_count = 0 then 54 if retry_count = 0 then
67 doretry := True
68 create person.make("SOME_SURNAME", "") 55 create person.make("SOME_SURNAME", "")
69 doretry := False
70 assert("CREATE_EDIT_PERSON_EMPTY_FIRSTNAME_1", False) 56 assert("CREATE_EDIT_PERSON_EMPTY_FIRSTNAME_1", False)
71 elseif retry_count = 1 then 57 elseif retry_count = 1 then
72 doretry := False
73 create person.make("SOME_SURNAME", "SOME_FIRSTNAME") 58 create person.make("SOME_SURNAME", "SOME_FIRSTNAME")
74 doretry := True
75 person.firstname := "" 59 person.firstname := ""
76 doretry := False
77 assert("CREATE_EDIT_PERSON_EMPTY_FIRSTNAME_3", False) 60 assert("CREATE_EDIT_PERSON_EMPTY_FIRSTNAME_3", False)
78 else
79 doretry := False
80 end 61 end
81 rescue 62 rescue
82 if doretry then 63 if not (create {EXCEPTIONS}).is_developer_exception then
83 retry_count := retry_count + 1 64 retry_count := retry_count + 1
84 retry 65 retry
85 end 66 end