public async void GetMany_MatchedDataReturned() { // Arrange var unitOfWork = new UnitOfWork(dbFactory); var repository = new RecurringPaymentRepository(dbFactory); var filterText = "Text"; repository.Add(new RecurringPaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" }, Note = filterText }); repository.Add(new RecurringPaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" } }); repository.Add(new RecurringPaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" } }); await unitOfWork.Commit(); // Act var resultList = repository.GetMany(x => x.Note == filterText).ToList(); // Assert Assert.NotNull(resultList); Assert.Equal(1, resultList.Count); }
public async void GetMany_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 resultList = repository.GetMany(x => x.Note == "text").ToList(); // Assert Assert.NotNull(resultList); Assert.False(resultList.Any()); }
public async void GetMany_MatchedDataReturned() { // 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(); } var filterText = "Text"; using (var dbContextScope = dbContextScopeFactory.Create()) { recurringPaymentRepository.Add(new RecurringPaymentEntity { ChargedAccount = testAccount, Note = filterText }); await dbContextScope.SaveChangesAsync(); } List <RecurringPaymentEntity> resultList; // Act using (var dbContextScope = dbContextScopeFactory.Create()) { recurringPaymentRepository.Add(new RecurringPaymentEntity { ChargedAccount = testAccount }); recurringPaymentRepository.Add(new RecurringPaymentEntity { ChargedAccount = testAccount }); await dbContextScope.SaveChangesAsync(); resultList = recurringPaymentRepository.GetMany(x => x.Note == filterText).ToList(); } // Assert Assert.NotNull(resultList); Assert.Equal(1, resultList.Count); }
public async void GetMany_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(); } List <RecurringPaymentEntity> resultList; // 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(); resultList = recurringPaymentRepository.GetMany(x => x.Note == "text").ToList(); } // Assert Assert.NotNull(resultList); Assert.False(resultList.Any()); }