public void Check_Operations_Date_on_an_account_with_multiple_retrieve_and_deposit() { FakeDateTimeWrapper fakeDateTimeWrapper = new FakeDateTimeWrapper(); Account account = new Account(18.15m, fakeDateTimeWrapper); FakeDateTimeWrapper.Date = new DateTime(2020, 1, 1); account.Deposit(18.15m); FakeDateTimeWrapper.Date = new DateTime(2020, 1, 5); account.Retrieve(5.42m); FakeDateTimeWrapper.Date = new DateTime(2020, 2, 12); account.Retrieve(12.73m); FakeDateTimeWrapper.Date = new DateTime(2020, 3, 3); account.Deposit(5.42m); List <Operation> operations = account.GetOperations(); Operation expectedFirstOperation = new Operation(OperationType.Deposit, 18.15m, 0, new DateTime(2020, 1, 1)); Operation expectedSecondOperation = new Operation(OperationType.Retrieve, 5.42m, 0, new DateTime(2020, 1, 5)); Operation expectedThirdOperation = new Operation(OperationType.Retrieve, 12.73m, 0, new DateTime(2020, 2, 12)); Operation expectedFourthOperation = new Operation(OperationType.Deposit, 5.42m, 0, new DateTime(2020, 3, 3)); Assert.AreEqual(4, operations.Count); Assert.AreEqual(expectedFirstOperation.Date, operations[0].Date); Assert.AreEqual(expectedSecondOperation.Date, operations[1].Date); Assert.AreEqual(expectedThirdOperation.Date, operations[2].Date); Assert.AreEqual(expectedFourthOperation.Date, operations[3].Date); }
public void Check_Show_Operations_on_an_account_with_multiple_retrieve_and_deposit() { FakeDateTimeWrapper fakeDateTimeWrapper = new FakeDateTimeWrapper(); Account account = new Account(18.15m, fakeDateTimeWrapper); FakeDateTimeWrapper.Date = new DateTime(2020, 1, 1); account.Deposit(18.15m); FakeDateTimeWrapper.Date = new DateTime(2020, 1, 5); account.Retrieve(5.42m); TextWriter outputText = new StringWriter(); Console.SetOut(outputText); account.ShowOperations(); string expectedoutputText = "01/01/2020 00:00:00 / Deposit / 18,15 / 36,30\r\n05/01/2020 00:00:00 / Retrieve / 5,42 / 30,88\r\n"; Assert.AreEqual(expectedoutputText, outputText.ToString()); }