public void GetList_WithFilter() { var accountRepo = new AccountRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testAccount = new Fixture().Create<AccountViewModel>(); testAccount.Id = 0; try { accountRepo.Save(testAccount); accountRepo.GetList(x => x.Id == testAccount.Id).First().Id.ShouldBe(testAccount.Id); accountRepo.GetList(x => x.Id == 99).FirstOrDefault().ShouldBeNull(); } finally { accountRepo.Delete(testAccount); } }
public void GetList_WithoutFilter() { var accountRepo = new AccountRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testAccount = new Fixture().Create<AccountViewModel>(); testAccount.Id = 0; try { accountRepo.Save(testAccount); var selectedAccount = accountRepo.GetList().First(); selectedAccount.Id.ShouldBe(testAccount.Id); selectedAccount.Name.ShouldBe(testAccount.Name); } finally { accountRepo.Delete(testAccount); } }
public void SaveAndUpdate_WithTargetAccount_NoDuplicates() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var accountRepository = new AccountRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var account = new Fixture().Create<AccountViewModel>(); account.Id = 0; accountRepository.Save(account); var testPayment = new Fixture().Create<PaymentViewModel>(); testPayment.Id = 0; testPayment.TargetAccount = account; paymentRepository.Save(testPayment); paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); var selected = paymentRepository.FindById(testPayment.Id); accountRepository.GetList(x => x.Name == testPayment.TargetAccount.Name).Count().ShouldBe(1); }