public When_Employer_Check_Details_Is_Submitted_Successfully() { _opportunityService = Substitute.For <IOpportunityService>(); _opportunityService.IsReferralOpportunityItemAsync(OpportunityItemId).Returns(true); var httpContextAccessor = Substitute.For <IHttpContextAccessor>(); var referralService = Substitute.For <IReferralService>(); var config = new MapperConfiguration(c => { c.AddMaps(typeof(EmployerDtoMapper).Assembly); c.ConstructServicesUsing(type => type.Name.Contains("LoggedInUserEmailResolver") ? new LoggedInUserEmailResolver <EmployerDetailsViewModel, EmployerDetailDto>(httpContextAccessor) : type.Name.Contains("LoggedInUserNameResolver") ? (object)new LoggedInUserNameResolver <EmployerDetailsViewModel, EmployerDetailDto>(httpContextAccessor) : type.Name.Contains("UtcNowResolver") ? new UtcNowResolver <EmployerDetailsViewModel, EmployerDetailDto>(new DateTimeProvider()) : null); }); var mapper = new Mapper(config); var employerController = new EmployerController(null, _opportunityService, referralService, mapper); var controllerWithClaims = new ClaimsBuilder <EmployerController>(employerController) .AddStandardUser() .AddUserName(ModifiedBy) .Build(); httpContextAccessor.HttpContext.Returns(controllerWithClaims.HttpContext); _result = controllerWithClaims.SaveCheckOpportunityEmployerDetailsAsync(_viewModel).GetAwaiter().GetResult(); }