public async void Get_MatchedDataReturned() { // Arrange var unitOfWork = new UnitOfWork(dbFactory); var repository = new RecurringPaymentRepository(dbFactory); var filterText = "Text"; var testEntry = new RecurringPaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" }, Note = filterText }; repository.Add(testEntry); repository.Add(new RecurringPaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" } }); repository.Add(new RecurringPaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" } }); await unitOfWork.Commit(); // Act var result = await repository.Get(x => x.Note == filterText); // Assert Assert.NotNull(result); Assert.Equal(testEntry.Id, result.Id); }
public async void Get_NothingMatched() { // Arrange var unitOfWork = new UnitOfWork(dbFactory); var repository = new RecurringPaymentRepository(dbFactory); repository.Add(new RecurringPaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" } }); repository.Add(new RecurringPaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" } }); repository.Add(new RecurringPaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" } }); await unitOfWork.Commit(); // Act var result = await repository.Get(x => x.Note == "text"); // Assert Assert.Null(result); }
public async void Get_MatchedDataReturned() { // Arrange var repository = new RecurringPaymentRepository(ambientDbContextLocator); var accountRepository = new AccountRepository(ambientDbContextLocator); AccountEntity testAccount; using (var dbContextScope = dbContextScopeFactory.Create()) { testAccount = new AccountEntity { Name = "testAccount" }; accountRepository.Add(testAccount); await dbContextScope.SaveChangesAsync(); } var filterText = "Text"; var testEntry = new RecurringPaymentEntity { ChargedAccount = testAccount, Note = filterText }; RecurringPaymentEntity result; // Act using (var dbContextScope = dbContextScopeFactory.Create()) { repository.Add(testEntry); repository.Add(new RecurringPaymentEntity { ChargedAccount = testAccount }); repository.Add(new RecurringPaymentEntity { ChargedAccount = testAccount }); await dbContextScope.SaveChangesAsync(); result = await repository.Get(x => x.Note == filterText); } // Assert Assert.NotNull(result); Assert.Equal(testEntry.Id, result.Id); }
public async void Get_NothingMatched() { // Arrange var recurringPaymentRepository = new RecurringPaymentRepository(ambientDbContextLocator); var accountRepository = new AccountRepository(ambientDbContextLocator); AccountEntity testAccount; using (var dbContextScope = dbContextScopeFactory.Create()) { testAccount = new AccountEntity { Name = "testAccount" }; accountRepository.Add(testAccount); await dbContextScope.SaveChangesAsync(); } RecurringPaymentEntity result; // Act using (var dbContextScope = dbContextScopeFactory.Create()) { recurringPaymentRepository.Add(new RecurringPaymentEntity { ChargedAccount = testAccount }); recurringPaymentRepository.Add(new RecurringPaymentEntity { ChargedAccount = testAccount }); recurringPaymentRepository.Add(new RecurringPaymentEntity { ChargedAccount = testAccount }); await dbContextScope.SaveChangesAsync(); result = await recurringPaymentRepository.Get(x => x.Note == "text"); } // Assert Assert.Null(result); }