From 1daf62f05c19e6f96d16d3688055dfd20d89d2b8 Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 23 May 2011 20:37:54 +0200 Subject: - add tests - remove notes - fix minamount for subaccounts --- bank-eiffel/account.e | 16 +++--- bank-eiffel/application.e | 5 -- bank-eiffel/bank.e | 6 --- bank-eiffel/person.e | 6 --- bank-eiffel/retiree.e | 8 +-- bank-eiffel/retireeaccount.e | 18 ++++--- bank-eiffel/student.e | 6 --- bank-eiffel/studentaccount.e | 16 +++--- bank-eiffel/tests/test_account.e | 111 ++++++++++++++++++++++++++++++++------- bank-eiffel/tests/test_person.e | 37 ++++--------- 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 @@ -note - description: "Summary description for {ACCOUNT}." - author: "" - date: "$Date$" - revision: "$Revision$" - class ACCOUNT @@ -57,14 +51,15 @@ feature {NONE} -- Initialization do create authorized_signers.make(1) add_authorized_signer (an_authorized_signer) - transfer_minamount := 2.0 - balance := 0.0 creditline := a_credit_line interest_debit := an_interest_debit interest_deposit := an_interest_deposit interest_deposit_range := an_interest_deposit_range interest_debit_range := an_interest_debit_range creditline_range := a_credit_line_range + + set_default_transfer_minamount + balance := 0.0 end feature -- Basic operations @@ -146,6 +141,11 @@ feature {NONE} -- Implementation transfer_minamount_assigned: transfer_minamount = a_transfer_minamount end + set_default_transfer_minamount + do + set_transfer_minamount (2.0) + end + set_creditline (a_creditline: like creditline) require 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 @@ -note - description : "bank application root class" - date : "$Date$" - revision : "$Revision$" - class APPLICATION 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 @@ -note - description: "Summary description for {BANK}." - author: "" - date: "$Date$" - revision: "$Revision$" - class BANK 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 @@ -note - description: "Summary description for {PERSON}." - author: "" - date: "$Date$" - revision: "$Revision$" - class PERSON 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 @@ -note - description: "Summary description for {RETIREE}." - author: "" - date: "$Date$" - revision: "$Revision$" - class RETIREE @@ -12,5 +6,5 @@ inherit create make - + end 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 @@ -note - description: "Summary description for {RETIREEACCOUNT}." - author: "" - date: "$Date$" - revision: "$Revision$" - class RETIREEACCOUNT inherit ACCOUNT - + redefine + set_default_transfer_minamount + end + create make +feature {NONE} -- Implementation + + set_default_transfer_minamount + do + set_transfer_minamount (1.0) + end + invariant authorized_signers_only_one: authorized_signers.count = 1 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 @@ -note - description: "Summary description for {STUDENT}." - author: "" - date: "$Date$" - revision: "$Revision$" - class STUDENT 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 @@ -note - description: "Summary description for {STUDENTACCOUNT}." - author: "" - date: "$Date$" - revision: "$Revision$" - class STUDENTACCOUNT inherit ACCOUNT + redefine + set_default_transfer_minamount + end create make +feature {NONE} -- Implementation + + set_default_transfer_minamount + do + set_transfer_minamount (1.0) + end + invariant authorized_signers_only_one: authorized_signers.count = 1 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 @@ -note - description: "[ - Eiffel tests that can be executed by testing tool. - ]" - author: "EiffelStudio test wizard" - date: "$Date$" - revision: "$Revision$" - testing: "type/manual" - class TEST_ACCOUNT @@ -23,11 +14,13 @@ feature -- Test routines account1: ACCOUNT account2: ACCOUNT do - create person1.make ("SOME_SURNAME_1", "SOME_FIRSTNAME_1") - create person2.make ("SOME_SURNAME_2", "SOME_FIRSTNAME_2") - create person3.make ("SOME_SURNAME_3", "SOME_FIRSTNAME_3") + create person1.make ("PERSON1", "PERSON1") + create person2.make ("PERSON2", "PERSON2") + create person3.make ("PERSON3", "PERSON3") create account1.make (person1, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + assert("CREATE_EDIT_ACCOUNT_MINAMOUNT", account1.transfer_minamount = 2.0) + assert("CREATE_EDIT_ACCOUNT_SIGNER_1", account1.get_authorized_signers.count = 1) account1.add_authorized_signer (person2) account1.add_authorized_signer (person2) @@ -66,20 +59,100 @@ feature -- Test routines CREATE_STUDENTACCOUNT local - person: STUDENT + student: STUDENT + account: STUDENTACCOUNT + do + create student.make("STUDENT", "STUDENT") + create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + assert("CREATE_STUDENTACCOUNT", attached {ACCOUNT} account) + assert("CREATE_STUDENTACCOUNT_MINAMOUNT", account.transfer_minamount = 1.0) + end + + CREATE_STUDENTACCOUNT_ONLY_STUDENTS + local account: STUDENTACCOUNT + student: STUDENT + person: PERSON + retiree: RETIREE + retry_count: INTEGER do - create person.make("SOME_SURNAME", "SOME_FIRSTNAME") - create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + create student.make("STUDENT", "STUDENT") + create person.make("PERSON", "PERSON") + create retiree.make("RETIREE", "RETIREE") + + if retry_count = 0 then + create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + assert("CREATE_STUDENTACCOUNT_ONLY_STUDENTS_1", False) + elseif retry_count = 1 then + create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + assert("CREATE_STUDENTACCOUNT_ONLY_STUDENTS_2", False) + elseif retry_count = 2 then + create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + account.add_authorized_signer (create {STUDENT}.make("STUDENT2", "STUDENT2")) + assert("CREATE_STUDENTACCOUNT_ONE_STUDENT_ONLY_1", False) + elseif retry_count = 3 then + create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + account.add_authorized_signer (person) + assert("CREATE_STUDENTACCOUNT_ONE_STUDENT_ONLY_2", False) + elseif retry_count = 4 then + create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + account.add_authorized_signer (retiree) + assert("CREATE_STUDENTACCOUNT_ONE_STUDENT_ONLY_3", False) + end + rescue + if not (create {EXCEPTIONS}).is_developer_exception then + retry_count := retry_count + 1 + retry + end end CREATE_RETIREEACCOUNT local - person: RETIREE + retiree: RETIREE account: RETIREEACCOUNT do - create person.make("SOME_SURNAME", "SOME_FIRSTNAME") - create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + create retiree.make("RETIREE", "RETIREE") + create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + assert("CREATE_RETIREEACCOUNT", attached {ACCOUNT} account) + assert("CREATE_RETIREEACCOUNT_MINAMOUNT", account.transfer_minamount = 1.0) end -end + + CREATE_RETIREEACCOUNT_ONLY_RETIREES + local + account: RETIREEACCOUNT + retiree: RETIREE + person: PERSON + student: STUDENT + retry_count: INTEGER + do + create retiree.make("RETIREE", "RETIREE") + create person.make("PERSON", "PERSON") + create student.make("STUDENT", "STUDENT") + + if retry_count = 0 then + create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + assert("CREATE_RETIREEACCOUNT_ONLY_RETIREES_1", False) + elseif retry_count = 1 then + create account.make(student, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + assert("CREATE_RETIREEACCOUNT_ONLY_RETIREES_2", False) + elseif retry_count = 2 then + create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + account.add_authorized_signer (create {RETIREE}.make("RETIREE2", "RETIREE2")) + assert("CREATE_RETIREEACCOUNT_ONE_RETIREE_ONLY_1", False) + elseif retry_count = 3 then + create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + account.add_authorized_signer (person) + assert("CREATE_RETIREEACCOUNT_ONE_RETIREE_ONLY_2", False) + elseif retry_count = 4 then + create account.make(retiree, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) + account.add_authorized_signer (student) + assert("CREATE_RETIREEACCOUNT_ONE_RETIREE_ONLY_3", False) + end + rescue + if not (create {EXCEPTIONS}).is_developer_exception then + retry_count := retry_count + 1 + retry + end + end +end 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 @@ -note - description: "[ - Eiffel tests that can be executed by testing tool. - ]" - author: "EiffelStudio test wizard" - date: "$Date$" - revision: "$Revision$" - testing: "type/manual" - class TEST_PERSON @@ -14,10 +5,11 @@ inherit EQA_TEST_SET feature -- Test routines - CREATE_EDIT_PERSON local person: PERSON + student: STUDENT + retiree: RETIREE do create person.make("SOME_SURNAME_1", "SOME_FIRSTNAME_1") assert("CREATE_EDIT_PERSON_FIRSTNAME_1", person.firstname.is_equal("SOME_FIRSTNAME_1")) @@ -27,31 +19,28 @@ feature -- Test routines assert("CREATE_EDIT_PERSON_FIRSTNAME_2", person.firstname.is_equal("SOME_FIRSTNAME_2")) person.surname := "SOME_SURNAME_2" assert("CREATE_EDIT_PERSON_SURNAME_2", person.surname.is_equal("SOME_SURNAME_2")) + + create student.make ("STUDENT_SURNAME", "STUDENT_FIRSTNAME") + assert("CREATE_EDIT_PERSON_STUDENT", attached {PERSON} student) + create retiree.make ("RETIREE_SURNAME", "RETIREE_FIRSTNAME") + assert("CREATE_EDIT_PERSON_RETIREE", attached {PERSON} student) end CREATE_EDIT_PERSON_EMPTY_SURNAME local person: PERSON retry_count: INTEGER - doretry: BOOLEAN do if retry_count = 0 then - doretry := True create person.make("", "SOME_FIRSTNAME") - doretry := False assert("CREATE_EDIT_PERSON_EMPTY_SURNAME_1", False) elseif retry_count = 1 then - doretry := False create person.make("SOME_SURNAME", "SOME_FIRSTNAME") - doretry := True person.surname := "" - doretry := False assert("CREATE_EDIT_PERSON_EMPTY_SURNAME_3", False) - else - doretry := False end rescue - if doretry then + if not (create {EXCEPTIONS}).is_developer_exception then retry_count := retry_count + 1 retry end @@ -61,25 +50,17 @@ feature -- Test routines local person: PERSON retry_count: INTEGER - doretry: BOOLEAN do if retry_count = 0 then - doretry := True create person.make("SOME_SURNAME", "") - doretry := False assert("CREATE_EDIT_PERSON_EMPTY_FIRSTNAME_1", False) elseif retry_count = 1 then - doretry := False create person.make("SOME_SURNAME", "SOME_FIRSTNAME") - doretry := True person.firstname := "" - doretry := False assert("CREATE_EDIT_PERSON_EMPTY_FIRSTNAME_3", False) - else - doretry := False end rescue - if doretry then + if not (create {EXCEPTIONS}).is_developer_exception then retry_count := retry_count + 1 retry end -- cgit v1.2.3