class TEST_ACCOUNT inherit EQA_TEST_SET feature -- Test routines CREATE_EDIT_ACCOUNT local person1: PERSON person2: PERSON person3: PERSON account1: ACCOUNT account2: ACCOUNT do 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) account1.add_authorized_signer (person3) account1.remove_authorized_signer (person3) assert("CREATE_EDIT_ACCOUNT_SIGNER_2", account1.get_authorized_signers.count = 2) assert("CREATE_EDIT_ACCOUNT_BALANCE_1", account1.balance = 0.0) account1.deposit (50.0, person1) account1.deposit (50.0, person2) -- balance = 100.0 account1.advance -- balance = 100.0 + 1% deposit account1.withdraw (100.0 + 100.0 * 0.01 + 50.0, person1) -- balance = -50.0 account1.creditline := -100.0 account1.withdraw (50.0, person1) -- balance = -100.0 account1.advance -- balance = -100.0 + 2% debit assert("CREATE_EDIT_ACCOUNT_BALANCE_2", account1.balance = -102.0) create account2.make(person3, 0.01, 0.02, -50, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) account2.deposit (102.0, person3) account2.transfer (102.0, person3, account1, person1) assert("CREATE_EDIT_ACCOUNT_BALANCE_3", account1.balance = 0.0 and account2.balance = 0.0) account1.interest_deposit := 0.01 account1.interest_deposit := 0.022 account1.interest_debit := 0.01 account1.interest_debit := 0.02 account1.creditline := -100.0 account1.creditline := -50.0 account1.transfer_minamount := 10.0 end ACCOUNT_CHECK_RANGES local person: PERSON account: ACCOUNT retry_count: INTEGER do create person.make("PERSON", "PERSON") create account.make(person, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) inspect retry_count when 0 then account.interest_deposit := 0.0 assert("ACCOUNT_CHECK_RANGES_INTEREST_DEPOSIT_MIN", False) when 1 then account.interest_deposit := 0.023 assert("ACCOUNT_CHECK_RANGES_INTEREST_DEPOSIT_MAX", False) when 2 then account.interest_debit := 0.0 assert("ACCOUNT_CHECK_RANGES_INTEREST_DEBIT_MIN", False) when 3 then account.interest_debit := 0.03 assert("ACCOUNT_CHECK_RANGES_INTEREST_DEBIT_MAX", False) when 4 then account.creditline := -101.0 assert("ACCOUNT_CHECK_RANGES_CREDITLINE_MIN", False) when 5 then account.creditline := -49.0 assert("ACCOUNT_CHECK_RANGES_CREDITLINE_MAX", False) when 6 then account.transfer_minamount := -1.0 assert("ACCOUNT_CHECK_RANGES_TRANSFER_MINAMOUNT_POSITIVE", False) else end rescue if not (create {EXCEPTIONS}).is_developer_exception then retry_count := retry_count + 1 retry end end ACCOUNT_CHECK_OPERATIONS local person1: PERSON account1: ACCOUNT person2: PERSON account2: ACCOUNT retry_count: INTEGER do create person1.make("PERSON1", "PERSON1") create person2.make("PERSON2", "PERSON2") create account1.make(person1, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) create account2.make(person2, 0.01, 0.02, -50.0, [0.01, 0.022], [0.01, 0.02], [-100.0, -50.0]) inspect retry_count when 0 then account1.deposit (10.0, person2) assert("ACCOUNT_CHECK_OPERATIONS_DEPOSIT_OTHER", False) when 1 then account1.withdraw (10.0, person2) assert("ACCOUNT_CHECK_OPERATIONS_WITHDRAW_OTHER", False) when 2 then account1.transfer (10.0, person2, account2, person2) assert("ACCOUNT_CHECK_OPERATIONS_TRANSFER_OTHER_1", False) when 3 then account1.transfer (10.0, person1, account2, person1) assert("ACCOUNT_CHECK_OPERATIONS_TRANSFER_OTHER_2", False) when 4 then account1.withdraw (51.0, person1) assert("ACCOUNT_CHECK_OPERATIONS_WITHDRAW_OVER_CREDIT", False) when 5 then account1.deposit (1.0, person1) assert("ACCOUNT_CHECK_OPERATIONS_DEPOSIT_BELOW_MINAMOUNT", False) when 6 then account1.withdraw (1.0, person1) assert("ACCOUNT_CHECK_OPERATIONS_WITHDRAW_BELOW_MINAMOUNT", False) when 7 then account1.transfer (1.0, person1, account2, person2) assert("ACCOUNT_CHECK_OPERATIONS_TRANSFER_BELOW_MINAMOUNT", False) when 8 then account1.remove_authorized_signer (person1) assert("ACCOUNT_CHECK_OPERATIONS_REMOVE_AUTHORIZED_SIGNER_EMPTY", False) else end rescue if retry_count /= 9 and not (create {EXCEPTIONS}).is_developer_exception then retry_count := retry_count + 1 retry end end CREATE_STUDENTACCOUNT local 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 STUDENTACCOUNT_ONLY_STUDENTS local account: STUDENTACCOUNT student: STUDENT person: PERSON retiree: RETIREE retry_count: INTEGER do create student.make("STUDENT", "STUDENT") create person.make("PERSON", "PERSON") create retiree.make("RETIREE", "RETIREE") inspect retry_count when 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("STUDENTACCOUNT_ONLY_STUDENTS_1", False) when 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("STUDENTACCOUNT_ONLY_STUDENTS_2", False) when 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("STUDENTACCOUNT_ONE_STUDENT_ONLY_1", False) when 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("STUDENTACCOUNT_ONE_STUDENT_ONLY_2", False) when 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("STUDENTACCOUNT_ONE_STUDENT_ONLY_3", False) else end rescue if not (create {EXCEPTIONS}).is_developer_exception then retry_count := retry_count + 1 retry end end CREATE_RETIREEACCOUNT local retiree: RETIREE account: RETIREEACCOUNT do 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 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") inspect retry_count when 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("RETIREEACCOUNT_ONLY_RETIREES_1", False) when 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("RETIREEACCOUNT_ONLY_RETIREES_2", False) when 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("RETIREEACCOUNT_ONE_RETIREE_ONLY_1", False) when 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("RETIREEACCOUNT_ONE_RETIREE_ONLY_2", False) when 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("RETIREEACCOUNT_ONE_RETIREE_ONLY_3", False) else end rescue if not (create {EXCEPTIONS}).is_developer_exception then retry_count := retry_count + 1 retry end end end