public When_OpportunityRepository_GetProviderReferrals_Is_Called() { var logger = Substitute.For <ILogger <OpportunityRepository> >(); var dbContext = InMemoryDbContext.Create(); var opportunity = new ValidOpportunityBuilder() .AddEmployer() .AddReferrals(isSelectedForReferral: true) //Not completed, is selected .Build(); dbContext.Add(opportunity); dbContext.SaveChanges(); var opportunityItem = opportunity.OpportunityItem.First(); _opportunityId = opportunity.Id; _referralId = opportunityItem.Referral.First().Id; _opportunityItemId = opportunity.OpportunityItem.First().Id; var repository = new OpportunityRepository(logger, dbContext); _result = repository.GetProviderReferralsAsync( 1, new List <int> { _opportunityItemId }) .GetAwaiter().GetResult(); }
public When_OpportunityRepository_Update_Is_Called() { var logger = Substitute.For <ILogger <GenericRepository <Domain.Models.Opportunity> > >(); using var dbContext = InMemoryDbContext.Create(); var entity = new ValidOpportunityBuilder().Build(); dbContext.Add(entity); dbContext.SaveChanges(); var repository = new GenericRepository <Domain.Models.Opportunity>(logger, dbContext); entity.EmployerContact = "Updated Employer Contact"; entity.EmployerContactPhone = "020 123 9999"; entity.EmployerContactEmail = "*****@*****.**"; entity.ModifiedOn = new DateTime(2019, 11, 01, 12, 30, 00); entity.ModifiedBy = "UpdateTestUser"; repository.UpdateAsync(entity).GetAwaiter().GetResult(); _result = repository.GetSingleOrDefaultAsync(x => x.Id == 1) .GetAwaiter().GetResult(); }