public void PrintStatement() { var firstCreditDate = new DateTime(2016, 03, 06); var debitDate = new DateTime(2020, 10, 12); var secondCreditDate = new DateTime(2019, 05, 18); _clockMock.SetupSequence(c => c.GetCurrentDate()) .Returns(firstCreditDate) .Returns(debitDate) .Returns(secondCreditDate); _atm.Deposit(250); _atm.Withdraw(50); _atm.Deposit(150); _atm.PrintStatement(); _statementPrinterMock.Verify(o => o.PrintHeader(), Times.Once); _statementPrinterMock.Verify(o => o.PrintBody( It.Is <List <Transaction> >( list => list[0].Amount == 250 && list[0].Date == firstCreditDate && list[1].Amount == -50 && list[1].Date == debitDate && list[2].Amount == 150 && list[2].Date == secondCreditDate) ), Times.Once ); }
public void Increase_Balance_On_Current_Statement_After_A_Deposit() { var consoleMock = Substitute.For<IConsole>(); var statementPrinter = new StatementPrinter(consoleMock); var account = new Account(new Transactions()); var atm = new Atm(statementPrinter, account); // act atm.Deposit(2000); atm.PrintStatement(); // assert consoleMock.Received().WriteLine(Arg.Is<string>(line => line.Contains("balance = 2000"))); }
public void PrintStatementCorrectly() { var transactions = new List <Transaction> { new Credit(150, _dateTime), new Debit(50, _dateTime), new Credit(200, _dateTime) }; _transactionRepositoryMock.Setup(t => t.GetTransactions()).Returns(transactions); _atm.PrintStatement(); _statementPrinterMock.Verify(o => o.PrintHeader(), Times.Exactly(1)); _statementPrinterMock.Verify(o => o.PrintBody( It.Is <List <Transaction> >( list => list[0].Amount == 150 && list[0].Date == _dateTime && list[1].Amount == -50 && list[1].Date == _dateTime && list[2].Amount == 200 && list[2].Date == _dateTime) ), Times.Once ); }