public When_OpportunityService_Is_Called_To_Create_Opportunity_Item()
        {
            var httpContextAccessor = Substitute.For <IHttpContextAccessor>();

            httpContextAccessor.HttpContext.Returns(new DefaultHttpContext
            {
                User = new ClaimsPrincipal(new ClaimsIdentity(new[]
                {
                    new Claim(ClaimTypes.GivenName, "adminUserName")
                }))
            });

            var config = new MapperConfiguration(c =>
            {
                c.AddMaps(typeof(OpportunityMapper).Assembly);
                c.ConstructServicesUsing(type =>
                                         type.Name.Contains("LoggedInUserEmailResolver") ?
                                         new LoggedInUserEmailResolver <OpportunityItemDto, OpportunityItem>(httpContextAccessor) :
                                         type.Name.Contains("LoggedInUserNameResolver") ?
                                         (object)new LoggedInUserNameResolver <OpportunityItemDto, OpportunityItem>(httpContextAccessor) :
                                         type.Name.Contains("UtcNowResolver") ?
                                         new UtcNowResolver <OpportunityItemDto, OpportunityItem>(new DateTimeProvider()) :
                                         null);
            });
            var mapper = new Mapper(config);

            _opportunityItemRepository = Substitute.For <IRepository <OpportunityItem> >();

            _googleMapApiClient = Substitute.For <IGoogleMapApiClient>();
            _googleMapApiClient.GetAddressDetailsAsync(Arg.Is <string>(s => s == "AA1 1AA")).Returns("Coventry");

            var opportunityPipelineReportWriter = Substitute.For <IFileWriter <OpportunityReportDto> >();
            var dateTimeProvider = Substitute.For <IDateTimeProvider>();

            var opportunityRepository  = Substitute.For <IOpportunityRepository>();
            var provisionGapRepository = Substitute.For <IRepository <ProvisionGap> >();
            var referralRepository     = Substitute.For <IRepository <Domain.Models.Referral> >();

            _opportunityItemRepository.CreateAsync(Arg.Any <OpportunityItem>())
            .Returns(OpportunityItemId);

            var opportunityService = new OpportunityService(mapper, opportunityRepository, _opportunityItemRepository,
                                                            provisionGapRepository, referralRepository, _googleMapApiClient,
                                                            opportunityPipelineReportWriter, dateTimeProvider);

            var dto = new OpportunityItemDto
            {
                OpportunityId             = OpportunityId,
                OpportunityType           = OpportunityType.Referral,
                RouteId                   = 5,
                Postcode                  = "AA1 1AA",
                SearchRadius              = 10,
                JobRole                   = "Test Title",
                PlacementsKnown           = true,
                Placements                = 3,
                SearchResultProviderCount = 15,
                IsSaved                   = true,
                IsSelectedForReferral     = true,
                IsCompleted               = true,
                EmployerFeedbackSent      = true
            };

            _result = opportunityService.CreateOpportunityItemAsync(dto).GetAwaiter().GetResult();
        }