public void EndofMonthManager_AccountIsPositive() { AccountViewModel account1 = new AccountViewModel { Id = 1, CurrentBalance = -100, }; var paymentRepoSetup = new Mock <IPaymentRepository>(); paymentRepoSetup.Setup(x => x.GetList(It.IsAny <Expression <Func <PaymentViewModel, bool> > >())).Returns(new List <PaymentViewModel> { new PaymentViewModel { Id = 10, TargetAccountId = 1, Amount = 100, Date = DateTime.Now, Type = PaymentType.Income }, new PaymentViewModel { Id = 15, TargetAccountId = 1, Amount = 100, Date = DateTime.Now, Type = PaymentType.Income } }); var accounts = new List <AccountViewModel> { new AccountViewModel { Id = 2, CurrentBalance = 100 }, account1 }; EndOfMonthManager testManager = new EndOfMonthManager(paymentRepoSetup.Object); testManager.CheckEndOfMonthBalanceForAccounts(accounts); account1.IsOverdrawn.ShouldBeFalse(); }
public void EndofMonthManager_AccountIsPositive() { Account account1 = new Account { Id = 1, CurrentBalance = -100, EndMonthWarning = "Should Not Show" }; var paymentDataAccess = new Mock <IDataAccess <Payment> >(); paymentDataAccess.Setup(x => x.LoadList(It.IsAny <Expression <Func <Payment, bool> > >())).Returns(new List <Payment> { new Payment { Id = 10, TargetAccountId = 1, Amount = 100, Date = DateTime.Now, Type = (int)PaymentType.Income }, new Payment { Id = 15, TargetAccountId = 1, Amount = 100, Date = DateTime.Now, Type = (int)PaymentType.Income } }); var paymentrepository = new PaymentRepository(paymentDataAccess.Object); paymentrepository.Load(); var accounts = new List <Account> { new Account { Id = 2, CurrentBalance = 100 }, account1 }; EndOfMonthManager testManager = new EndOfMonthManager(paymentrepository); testManager.CheckEndOfMonthBalanceForAccounts(accounts); account1.EndMonthWarning.ShouldBe(" "); }
public void EndofMonthManager_AccountIsNegative() { Account account1 = new Account { Id = 1, CurrentBalance = 100, EndMonthWarning = "Should Not Show" }; var paymentDataAccess = new Mock <IDataAccess <Payment> >(); paymentDataAccess.Setup(x => x.LoadList(null)).Returns(new List <Payment> { new Payment { Id = 10, ChargedAccountId = 1, Amount = 100, Date = DateTime.Now }, new Payment { Id = 15, ChargedAccountId = 1, Amount = 100, Date = DateTime.Now } }); var paymentrepository = new PaymentRepository(paymentDataAccess.Object); paymentrepository.Load(); var accounts = new List <Account> { new Account { Id = 2, CurrentBalance = 100 }, account1 }; EndOfMonthManager testManager = new EndOfMonthManager(paymentrepository); testManager.CheckEndOfMonthBalanceForAccounts(accounts); Assert.AreEqual(account1.EndMonthWarning, "Negative at end of month"); }