Exemplo n.º 1
0
def main():
    account = Account(TransactionRepository(Clock()),
                      StatementPrinter(Console()))
    account.deposit(1000)
    account.withdraw(100)
    account.deposit(500)
    account.print_statement()
Exemplo n.º 2
0
    def test_print_statement_containing_all_transactions(self):
        console = mock()
        clock = mock()

        when(clock).date_as_string().thenReturn('01/04/2015').thenReturn(
            '02/04/2015').thenReturn('10/04/2015')

        account = Account(TransactionRepository(clock),
                          StatementPrinter(console))
        account.deposit(1000)
        account.withdraw(100)
        account.deposit(500)

        account.print_statement()

        inorder.verify(console).print_line('DATE | AMOUNT | BALANCE')
        inorder.verify(console).print_line('10/04/2015 | 500.00 | 1400.00')
        inorder.verify(console).print_line('02/04/2015 | -100.00 | 900.00')
        inorder.verify(console).print_line('01/04/2015 | 1000.00 | 1000.00')
 def setUp(self):
     self.clock = mock()
     self.transaction_repository = TransactionRepository(self.clock)