public void Save_WithTargetAccount() { 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.ChargedAccount = account; testPayment.TargetAccount = null; paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); var selected = paymentRepository.FindById(testPayment.Id); selected.ShouldNotBeNull(); selected.ShouldBeInstanceOf <PaymentViewModel>(); selected.ChargedAccount.ShouldNotBeNull(); selected.ChargedAccount.Id.ShouldBe(selected.ChargedAccountId); selected.ChargedAccount.Id.ShouldBe(testPayment.ChargedAccount.Id); paymentRepository.Delete(testPayment); paymentRepository.FindById(testPayment.Id).ShouldBeNull(); }
public void Save_ExistingEntryUpdated() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testPayment = new Fixture().Create<PaymentViewModel>(); testPayment.Id = 0; try { paymentRepository.Save(testPayment); paymentRepository.FindById(testPayment.Id).ShouldNotBeNull(); const string updatedNote = "FOOOOOOOOOO"; testPayment.Note = updatedNote; paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); paymentRepository.FindById(testPayment.Id).Note.ShouldBe(updatedNote); } finally { paymentRepository.Delete(testPayment); } }
public void Save_WithCategory() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var categoryRepository = new CategoryRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testCategory = new Fixture().Create <CategoryViewModel>(); testCategory.Id = 0; categoryRepository.Save(testCategory); var testPayment = new Fixture().Create <PaymentViewModel>(); testPayment.Id = 0; testPayment.Category = testCategory; paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); var selected = paymentRepository.FindById(testPayment.Id); selected.ShouldNotBeNull(); selected.ShouldBeInstanceOf <PaymentViewModel>(); selected.Category.ShouldNotBeNull(); selected.Category.Id.ShouldBe(selected.CategoryId.Value); selected.Category.Id.ShouldBe(testPayment.Category.Id); paymentRepository.Delete(testPayment); paymentRepository.FindById(testPayment.Id).ShouldBeNull(); }
public void PaymentRepository_Delete() { var paymentDataAccessSetup = new Mock <IDataAccess <Payment> >(); paymentDataAccessSetup.Setup(x => x.LoadList(null)).Returns(new List <Payment>()); var repository = new PaymentRepository(paymentDataAccessSetup.Object); var account = new Account { Id = 2, Name = "TestAccount" }; var payment = new Payment { ChargedAccount = account, ChargedAccountId = 2, Amount = 20 }; repository.Save(payment); Assert.AreSame(payment, repository.GetList().ToList()[0]); repository.Delete(payment); Assert.IsFalse(repository.GetList().Any()); }
public void FindById_WithRecurringPayment() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testPayment = new Fixture().Create <PaymentViewModel>(); testPayment.Id = 0; testPayment.RecurringPaymentId = 0; testPayment.RecurringPayment.Id = 0; testPayment.IsRecurring = true; paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); var selected = paymentRepository.FindById(testPayment.Id); selected.ShouldNotBeNull(); selected.ShouldBeInstanceOf <PaymentViewModel>(); selected.RecurringPayment.ShouldNotBeNull(); selected.RecurringPayment.Id.ShouldBe(selected.RecurringPaymentId); selected.RecurringPayment.Id.ShouldBe(testPayment.RecurringPayment.Id); paymentRepository.Delete(testPayment); paymentRepository.FindById(testPayment.Id).ShouldBeNull(); }
public void Delete_WithChildren_PaymentDeleted() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var categoryRepository = new CategoryRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var category = new Fixture().Create <CategoryViewModel>(); category.Id = 0; categoryRepository.Save(category); var testPayment = new Fixture().Create <PaymentViewModel>(); testPayment.Id = 0; testPayment.Category = category; paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); var payment = paymentRepository.FindById(testPayment.Id); payment.ShouldNotBeNull(); payment.Category.ShouldNotBeNull(); paymentRepository.Delete(testPayment); paymentRepository.FindById(testPayment.Id).ShouldBeNull(); categoryRepository.FindById(testPayment.Category.Id).ShouldNotBeNull(); }
public async void Test_PaymentRepository_DeleteAsync(PaymentModel payment) { await _connection.OpenAsync(); try { using (var ctx = new AccountContext(_options)) { await ctx.Database.EnsureCreatedAsync(); await ctx.Payments.AddAsync(payment); await ctx.SaveChangesAsync(); } using (var ctx = new AccountContext(_options)) { var payments = new PaymentRepository(ctx); await payments.Delete(1); await ctx.SaveChangesAsync(); Assert.Empty(await ctx.Payments.ToListAsync()); } } finally { await _connection.CloseAsync(); } }
public IActionResult DeletePayment([FromRoute] string typeId, [FromRoute] string paymentId) { try { var payment = _repository.GetByUser(UserID, paymentId); if (payment == null || payment.PaymentType != typeId) { return(BadRequest("Invalid payment")); } if (!string.IsNullOrWhiteSpace(payment.PaymentReceipt)) { _dropboxService.DeletePathIfExists(payment.PaymentReceipt); } if (!string.IsNullOrWhiteSpace(payment.PaymentDocument)) { _dropboxService.DeletePathIfExists(payment.PaymentDocument); } _repository.Delete(paymentId); return(NoContent()); } catch (Exception) { throw; } }
public void Test_DrinkCanRepository_Reset() { using (IPaymentRepository repo = new PaymentRepository()) { //Arrange var payment1 = new Payment { PaymentID = 1, Amount = 3.50m, Type = PaymentType.Cash }; repo.Add(payment1); var payment2 = new Payment { PaymentID = 1, Amount = 1.50m, Type = PaymentType.CreditCard }; repo.Add(payment2); //Act repo.Reset(); var criteria = new PaymentFindCriteria(); var result = repo.FindByCriteria(criteria).FirstOrDefault(); repo.Delete(result); var updatedList = repo.FindByCriteria(criteria); //Assert Assert.AreEqual(0, updatedList.Count()); } }
public void Delete(int id) { var club = _paymentRepository.GetAll().First(c => c.Id == id); _paymentRepository.Delete(club); _paymentRepository.Save(); }
public async void Delete_EntryMatchedFilterDeleted() { // Arrange var factory = new DbFactory(); var unitOfWork = new UnitOfWork(factory); var filterText = "Text"; var repository = new PaymentRepository(factory); var testEntry1 = new PaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" }, Note = filterText }; var testEntry2 = new PaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" } }; repository.Add(testEntry1); repository.Add(testEntry2); await unitOfWork.Commit(); // Act repository.Delete(x => x.Note == filterText); await unitOfWork.Commit(); // Assert Assert.Equal(1, repository.GetAll().Count()); }
public void Delete(object obj, EventArgs e) { try { if (m_prn.ID > 0) { this.Cursor = Cursors.WaitCursor; if (KryptonMessageBox.Show("Are you sure to delete this record?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { this.Cursor = Cursors.Default; return; } r_soinv.Delete(m_prn); ClearForm(); setEnableForm(true); setEditMode(EditMode.New); textBoxCode.Focus(); this.Cursor = Cursors.Default; } } catch (Exception x) { KryptonMessageBox.Show(x.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { this.Cursor = Cursors.Default; } }
public async void Delete_EntryNotFound() { // Arrange var paymentRepository = new PaymentRepository(ambientDbContextLocator); var accountRepository = new AccountRepository(ambientDbContextLocator); var testAccount = new AccountEntity { Name = "testAccount" }; using (var dbContextScope = dbContextScopeFactory.Create()) { accountRepository.Add(testAccount); await dbContextScope.SaveChangesAsync(); } var testEntry = new PaymentEntity { ChargedAccount = testAccount }; // Act / Assert using (var dbContextScope = dbContextScopeFactory.Create()) { paymentRepository.Delete(testEntry); await Assert.ThrowsAsync <DbUpdateConcurrencyException>(async() => await dbContextScope.SaveChangesAsync()); } }
public void Save_ExistingEntryUpdated() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testPayment = new Fixture().Create <PaymentViewModel>(); testPayment.Id = 0; try { paymentRepository.Save(testPayment); paymentRepository.FindById(testPayment.Id).ShouldNotBeNull(); const string updatedNote = "FOOOOOOOOOO"; testPayment.Note = updatedNote; paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); paymentRepository.FindById(testPayment.Id).Note.ShouldBe(updatedNote); } finally { paymentRepository.Delete(testPayment); } }
public void PaymentRepository_Delete() { var accountRepositorySetup = new Mock <IAccountRepository>(); accountRepositorySetup.SetupGet(x => x.Data).Returns(new ObservableCollection <Account>()); var categoryDataAccessSetup = new Mock <IRepository <Category> >(); categoryDataAccessSetup.SetupGet(x => x.Data).Returns(new ObservableCollection <Category>()); var paymentDataAccessMock = new PaymentDataAccessMock(); var repository = new PaymentRepository(new PaymentDataAccessMock(), new RecurringPaymentDataAccessMock(), accountRepositorySetup.Object, categoryDataAccessSetup.Object, new Mock <INotificationService>().Object); var account = new Account { Id = 2, Name = "TestAccount" }; var payment = new Payment { ChargedAccount = account, ChargedAccountId = 2, Amount = 20 }; repository.Save(payment); Assert.AreSame(payment, repository.Data[0]); repository.Delete(payment); Assert.IsFalse(repository.Data.Any()); }
public async Task <IActionResult> Delete(int id) { Payment payment = await _paymentRepository.GetByID(id); await _paymentRepository.Delete(id); return(RedirectToAction(nameof(ProjectPayments), new { isSuccess = true, projectId = payment.ProjectId, Title = payment.ProjectName })); }
public void DeletePayment() { using (var uow = new CapriconContext()) { var paymentRep = new PaymentRepository(uow); var existingPayment = paymentRep.Find(p => p.PaymentId == 2).FirstOrDefault(); Assert.IsNotNull(existingPayment); int paymentId; if (existingPayment != null) { paymentId = existingPayment.PaymentId; //Delete payment paymentRep.Delete(existingPayment); try { uow.SaveChanges(); } catch (DbEntityValidationException ex) { //Retrieve validation errors ex.EntityValidationErrors.ToList().ForEach ( v => { v.ValidationErrors.ToList().ForEach ( e => { System.Diagnostics.Debug.WriteLine(e.ErrorMessage); } ); } ); Assert.Fail("Test failed"); } Assert.IsNull(paymentRep.Find(p => p.PaymentId == paymentId).FirstOrDefault()); } else //no payments were selected { Assert.Fail("No payment was selected"); } } }
public void Delete_PaymentDeleted() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testPayment = new Fixture().Create <PaymentViewModel>(); testPayment.Id = 0; paymentRepository.Save(testPayment); PaymentRepository.IsCacheMarkedForReload = true; paymentRepository.FindById(testPayment.Id).ShouldNotBeNull(); paymentRepository.Delete(testPayment); paymentRepository.FindById(testPayment.Id).ShouldBeNull(); }
public async void Delete_EntryMatchedFilterDeleted() { // Arrange var filterText = "Text"; var paymentRepository = new PaymentRepository(ambientDbContextLocator); var accountRepository = new AccountRepository(ambientDbContextLocator); var testAccount = new AccountEntity { Name = "testAccount" }; using (var dbContextScope = dbContextScopeFactory.Create()) { accountRepository.Add(testAccount); await dbContextScope.SaveChangesAsync(); } var testEntry1 = new PaymentEntity { ChargedAccount = testAccount, Note = filterText }; var testEntry2 = new PaymentEntity { ChargedAccount = testAccount }; // Act using (var dbContextScope = dbContextScopeFactory.Create()) { paymentRepository.Add(testEntry1); paymentRepository.Add(testEntry2); await dbContextScope.SaveChangesAsync(); } using (var dbContextScope = dbContextScopeFactory.Create()) { paymentRepository.Delete(x => x.Note == filterText); await dbContextScope.SaveChangesAsync(); } // Assert using (dbContextScopeFactory.CreateReadOnly()) { Assert.Equal(1, paymentRepository.GetAll().Count()); } }
public async void Delete_EntryNotFound() { // Arrange var unitOfWork = new UnitOfWork(dbFactory); var repository = new PaymentRepository(dbFactory); var testEntry = new PaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" } }; // Act repository.Delete(testEntry); // Assert await Assert.ThrowsAsync <DbUpdateConcurrencyException>(async() => await unitOfWork.Commit()); }
public void Save_IdSet() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testPayment = new Fixture().Create<PaymentViewModel>(); testPayment.Id = 0; try { paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); testPayment.Id.ShouldBeGreaterThan(0); } finally { paymentRepository.Delete(testPayment); } }
public void FindById_WithRecurringPayment_RecPaymentDependenciesLoaded() { 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 fixture = new Fixture(); var account = fixture.Create <AccountViewModel>(); account.Id = 0; accountRepository.Save(account); var testPayment = fixture.Create <PaymentViewModel>(); testPayment.Id = 0; testPayment.RecurringPaymentId = 0; testPayment.RecurringPayment.Id = 0; testPayment.IsRecurring = true; testPayment.ChargedAccount = account; testPayment.RecurringPayment.ChargedAccount = account; paymentRepository.Save(testPayment); PaymentRepository.IsCacheMarkedForReload = true; var selected = paymentRepository.FindById(testPayment.Id); selected.ShouldNotBeNull(); selected.ShouldBeInstanceOf <PaymentViewModel>(); selected.RecurringPayment.ShouldNotBeNull(); selected.RecurringPayment.Id.ShouldBe(selected.RecurringPaymentId); selected.RecurringPayment.Id.ShouldBe(testPayment.RecurringPayment.Id); selected.RecurringPayment.ChargedAccount.ShouldNotBeNull(); paymentRepository.Delete(testPayment); paymentRepository.FindById(testPayment.Id).ShouldBeNull(); }
public void Save_IdSet() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testPayment = new Fixture().Create <PaymentViewModel>(); testPayment.Id = 0; try { paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); testPayment.Id.ShouldBeGreaterThan(0); } finally { paymentRepository.Delete(testPayment); } }
private void btnDeletePayment_Click(object sender, System.EventArgs e) { if (gridPayments.SelectedRows.Count == 0) { return; } Payment currentPayment = gridPayments.SelectedRows[0].Tag as Payment; if (currentPayment == null) { return; } if (MessageBox.Show("Вы уверенны, что хотите удалить платёж от " + currentPayment.DatePayment.ToShortDateString() + "?", "Удаление платежа", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _paymentRepository.Delete(currentPayment); gridPayments.Rows.Clear(); LoadPayments(); } }
public HttpResponseMessage DeletePayment(int id) { Payment Payment = PaymentRepository.Get(t => t.PaymentId == id); if (Payment == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } PaymentRepository.Delete(Payment); try { unitOfWork.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK, Payment)); }
public void GetList_WithFilter() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testPayment = new Fixture().Create <PaymentViewModel>(); testPayment.Id = 0; try { paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); paymentRepository.GetList(x => x.Id == testPayment.Id).First().Id.ShouldBe(testPayment.Id); paymentRepository.GetList(x => x.Id == 99).FirstOrDefault().ShouldBeNull(); } finally { paymentRepository.Delete(testPayment); } }
public async void Delete_EntryDeleted() { // Arrange var unitOfWork = new UnitOfWork(dbFactory); var repository = new PaymentRepository(dbFactory); var testEntry = new PaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" } }; repository.Add(testEntry); await unitOfWork.Commit(); // Act repository.Delete(testEntry); await unitOfWork.Commit(); // Assert Assert.Equal(0, repository.GetAll().Count()); }
public async void Delete_EntryDeleted() { // Arrange var paymentRepository = new PaymentRepository(ambientDbContextLocator); var accountRepository = new AccountRepository(ambientDbContextLocator); var testAccount = new AccountEntity { Name = "testAccount" }; using (var dbContextScope = dbContextScopeFactory.Create()) { accountRepository.Add(testAccount); await dbContextScope.SaveChangesAsync(); } var testEntry = new PaymentEntity { ChargedAccount = testAccount }; // Act using (var dbContextScope = dbContextScopeFactory.Create()) { paymentRepository.Add(testEntry); await dbContextScope.SaveChangesAsync(); } using (var dbContextScope = dbContextScopeFactory.Create()) { paymentRepository.Delete(testEntry); await dbContextScope.SaveChangesAsync(); } // Assert using (dbContextScopeFactory.CreateReadOnly()) { Assert.Equal(0, paymentRepository.GetAll().Count()); } }
public void GetList_WithoutFilter() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testPayment = new Fixture().Create <PaymentViewModel>(); testPayment.Id = 0; try { paymentRepository.Save(testPayment); PaymentRepository.IsCacheMarkedForReload = true; var selectedAccount = paymentRepository.GetList().First(); selectedAccount.Id.ShouldBe(testPayment.Id); selectedAccount.Amount.ShouldBe(testPayment.Amount); } finally { paymentRepository.Delete(testPayment); } }
public void Delete_WithChildren_PaymentDeleted() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var categoryRepository = new CategoryRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var category = new Fixture().Create<CategoryViewModel>(); category.Id = 0; categoryRepository.Save(category); var testPayment = new Fixture().Create<PaymentViewModel>(); testPayment.Id = 0; testPayment.Category = category; paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); var payment = paymentRepository.FindById(testPayment.Id); payment.ShouldNotBeNull(); payment.Category.ShouldNotBeNull(); paymentRepository.Delete(testPayment); paymentRepository.FindById(testPayment.Id).ShouldBeNull(); categoryRepository.FindById(testPayment.Category.Id).ShouldNotBeNull(); }
public void Delete(int id) { _repository.Delete(id); }
public async Task Delete(int id) { await _paymentRepository.Delete(id); }
public IHttpActionResult PaymentMethodDelete(int id) { paymentRepository.Delete(id); return(StatusCode(HttpStatusCode.OK)); }
public void Save_WithCategory() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var categoryRepository = new CategoryRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testCategory = new Fixture().Create<CategoryViewModel>(); testCategory.Id = 0; categoryRepository.Save(testCategory); var testPayment = new Fixture().Create<PaymentViewModel>(); testPayment.Id = 0; testPayment.Category = testCategory; paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); var selected = paymentRepository.FindById(testPayment.Id); selected.ShouldNotBeNull(); selected.ShouldBeInstanceOf<PaymentViewModel>(); selected.Category.ShouldNotBeNull(); selected.Category.Id.ShouldBe(selected.CategoryId.Value); selected.Category.Id.ShouldBe(testPayment.Category.Id); paymentRepository.Delete(testPayment); paymentRepository.FindById(testPayment.Id).ShouldBeNull(); }
public void Save_WithTargetAccount() { 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.ChargedAccount = account; testPayment.TargetAccount = null; paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); var selected = paymentRepository.FindById(testPayment.Id); selected.ShouldNotBeNull(); selected.ShouldBeInstanceOf<PaymentViewModel>(); selected.ChargedAccount.ShouldNotBeNull(); selected.ChargedAccount.Id.ShouldBe(selected.ChargedAccountId); selected.ChargedAccount.Id.ShouldBe(testPayment.ChargedAccount.Id); paymentRepository.Delete(testPayment); paymentRepository.FindById(testPayment.Id).ShouldBeNull(); }
public void FindById_WithRecurringPayment() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testPayment = new Fixture().Create<PaymentViewModel>(); testPayment.Id = 0; testPayment.RecurringPaymentId = 0; testPayment.RecurringPayment.Id = 0; testPayment.IsRecurring = true; paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); var selected = paymentRepository.FindById(testPayment.Id); selected.ShouldNotBeNull(); selected.ShouldBeInstanceOf<PaymentViewModel>(); selected.RecurringPayment.ShouldNotBeNull(); selected.RecurringPayment.Id.ShouldBe(selected.RecurringPaymentId); selected.RecurringPayment.Id.ShouldBe(testPayment.RecurringPayment.Id); paymentRepository.Delete(testPayment); paymentRepository.FindById(testPayment.Id).ShouldBeNull(); }
public void DeletePayment() { using (var uow = new CapriconContext()) { var paymentRep = new PaymentRepository(uow); var existingPayment = paymentRep.Find(p => p.PaymentId == 2).FirstOrDefault(); Assert.IsNotNull(existingPayment); int paymentId; if (existingPayment != null) { paymentId = existingPayment.PaymentId; //Delete payment paymentRep.Delete(existingPayment); try { uow.SaveChanges(); } catch (DbEntityValidationException ex) { //Retrieve validation errors ex.EntityValidationErrors.ToList().ForEach ( v => { v.ValidationErrors.ToList().ForEach ( e => { System.Diagnostics.Debug.WriteLine(e.ErrorMessage); } ); } ); Assert.Fail("Test failed"); } Assert.IsNull(paymentRep.Find(p => p.PaymentId == paymentId).FirstOrDefault()); } else //no payments were selected Assert.Fail("No payment was selected"); } }
public void GetList_WithRecurringPayment_RecPaymentDependenciesLoaded() { 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 fixture = new Fixture(); var account = fixture.Create<AccountViewModel>(); account.Id = 0; accountRepository.Save(account); var testPayment = fixture.Create<PaymentViewModel>(); testPayment.Id = 0; testPayment.RecurringPaymentId = 0; testPayment.RecurringPayment.Id = 0; testPayment.IsRecurring = true; testPayment.ChargedAccount = account; testPayment.RecurringPayment.ChargedAccount = account; paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); var selected = paymentRepository.GetList(x => x.Id == testPayment.Id).First(); selected.ShouldNotBeNull(); selected.ShouldBeInstanceOf<PaymentViewModel>(); selected.RecurringPayment.ShouldNotBeNull(); selected.RecurringPayment.Id.ShouldBe(selected.RecurringPaymentId); selected.RecurringPayment.Id.ShouldBe(testPayment.RecurringPayment.Id); selected.RecurringPayment.ChargedAccount.ShouldNotBeNull(); paymentRepository.Delete(testPayment); paymentRepository.FindById(testPayment.Id).ShouldBeNull(); }
public void GetList_WithoutFilter() { var paymentRepository = new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(), new MvxWpfFileStore(FILE_ROOT))); var testPayment = new Fixture().Create<PaymentViewModel>(); testPayment.Id = 0; try { paymentRepository.Save(testPayment); paymentRepository.ReloadCache(); var selectedAccount = paymentRepository.GetList().First(); selectedAccount.Id.ShouldBe(testPayment.Id); selectedAccount.Amount.ShouldBe(testPayment.Amount); } finally { paymentRepository.Delete(testPayment); } }