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 AddCreditCorrectly() { _atm.Deposit(250); _transactionRepositoryMock .Verify(t => t.AddCredit(It.Is <Credit>(d => d.Amount == 250 && d.Date == _dateTime)), Times.Once()); }
static void Main() { var atm = new Atm(); while (true) { int option; Console.WriteLine(); Console.WriteLine("Menu:"); Console.WriteLine("1. Create Account"); Console.WriteLine("2. Deposit"); Console.WriteLine(); Console.Write("Please make a selection: "); var input = int.TryParse(Console.ReadLine(), out option); Console.WriteLine("-----------------"); switch (option) { case 1: atm.CreateAccount(); break; case 2: atm.Deposit(); break; } } }
public void Deposit_Should_Increase_Balance_by_50_Dollars() { Atm sut = new Atm(200); sut.Deposit(); int actualBalance = sut.CheckBalance(); Assert.Equal(250, actualBalance); }
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 verify_that_deposit_adds_one_line_of_history() { DateTime today = new DateTime(2012, 1, 10); Id clientId = new Id("toto"); decimal amountOfMoney = new decimal(1000); decimal initialBalance = 0; Atm atm = new Atm(null, clockMock.Object, cardReaderMock.Object, historyMock.Object, null); SetupCardReader(clientId); Balance initialBalanceFromHistory = new Balance(initialBalance); historyMock.Setup(history => history.GetBalance(clientId)) .Returns(initialBalanceFromHistory); Balance newBalance = initialBalanceFromHistory.Calculate(amountOfMoney); clockMock.Setup(clock => clock.Today()) .Returns(today); atm.Deposit(amountOfMoney); historyMock.Verify(history => history.AddLine(amountOfMoney, clientId, newBalance, today)); }