public void Save_EmptyName_CorrectDefault() { var testList = new List<Account>(); const string nameInput = ""; var accountDataAccessSetup = new Mock<IDataAccess<Account>>(); accountDataAccessSetup.Setup(x => x.SaveItem(It.IsAny<Account>())) .Callback((Account acc) => testList.Add(acc)); accountDataAccessSetup.Setup(x => x.LoadList(null)).Returns(new List<Account>()); var accountRepository = new AccountRepository(accountDataAccessSetup.Object, new Mock<INotificationService>().Object); var account = new Account { Name = nameInput, CurrentBalance = 6034 }; accountRepository.Save(account); Assert.AreSame(testList[0], account); Assert.AreSame(testList[0].Name, account.Name); }
public void CheckRecurringPayments_Daily_CorrectPaymentsCreated() { //Setup var sqliteConnector = new SqliteConnectionCreator(new WindowsSqliteConnectionFactory(), new MvxWindowsCommonFileStore()); var accountRepo = new AccountRepository(new AccountDataAccess(sqliteConnector)); var paymentRepo = new PaymentRepository(new PaymentDataAccess(sqliteConnector), new RecurringPaymentDataAccess(sqliteConnector), accountRepo, new CategoryRepository(new CategoryDataAccess(sqliteConnector))); var account = new Account { Name = "test1", CurrentBalance = 100 }; accountRepo.Save(account); var payment = new Payment { ChargedAccount = account, Amount = 10, Date = DateTime.Today.AddDays(-1), IsRecurring = true }; payment.RecurringPayment = RecurringPaymentHelper. GetRecurringFromPayment(payment, true, (int) PaymentRecurrence.Daily, DateTime.Now.AddYears(1)); paymentRepo.Save(payment); //Execution new RecurringPaymentManager(paymentRepo, accountRepo).CheckRecurringPayments(); //Assert Assert.AreEqual(90, account.CurrentBalance); Assert.AreEqual(90, accountRepo.Data[0].CurrentBalance); Assert.AreEqual(2, paymentRepo.Data.Count); Assert.IsTrue(paymentRepo.Data[0].IsCleared); Assert.IsTrue(paymentRepo.Data[1].IsCleared); Assert.IsTrue(paymentRepo.Data[0].IsRecurring); Assert.IsTrue(paymentRepo.Data[1].IsRecurring); Assert.AreNotEqual(0, paymentRepo.Data[0].RecurringPaymentId); Assert.AreNotEqual(0, paymentRepo.Data[1].RecurringPaymentId); Assert.IsNotNull(paymentRepo.Data[0].RecurringPayment); Assert.IsNotNull(paymentRepo.Data[1].RecurringPayment); }