public SegmentServiceSegmentsHealthCheckAsyncTests()
        {
            logService = A.Fake <ILogService>();
            careerPathSegmentService           = A.Fake <ISegmentRefreshService <CareerPathSegmentClientOptions> >();
            currentOpportunitiesSegmentService = A.Fake <ISegmentRefreshService <CurrentOpportunitiesSegmentClientOptions> >();
            howToBecomeSegmentService          = A.Fake <ISegmentRefreshService <HowToBecomeSegmentClientOptions> >();
            overviewBannerSegmentService       = A.Fake <ISegmentRefreshService <OverviewBannerSegmentClientOptions> >();
            relatedCareersSegmentService       = A.Fake <ISegmentRefreshService <RelatedCareersSegmentClientOptions> >();
            whatItTakesSegmentService          = A.Fake <ISegmentRefreshService <WhatItTakesSegmentClientOptions> >();
            whatYouWillDoSegmentService        = A.Fake <ISegmentRefreshService <WhatYouWillDoSegmentClientOptions> >();

            var          baseAddress = new Uri("https://nowhere.com");
            const string endpoint    = "segment/{0}/contents";

            careerPathSegmentService.SegmentClientOptions = new CareerPathSegmentClientOptions
            {
                BaseAddress = baseAddress,
                Endpoint    = endpoint,
                OfflineHtml = $"<h3>{careerPathSegmentService.GetType().Name} is offline</h3>",
            };
            currentOpportunitiesSegmentService.SegmentClientOptions = new CurrentOpportunitiesSegmentClientOptions
            {
                BaseAddress = baseAddress,
                Endpoint    = endpoint,
                OfflineHtml = $"<h3>{currentOpportunitiesSegmentService.GetType().Name} is offline</h3>",
            };
            howToBecomeSegmentService.SegmentClientOptions = new HowToBecomeSegmentClientOptions
            {
                BaseAddress = baseAddress,
                Endpoint    = endpoint,
                OfflineHtml = $"<h3>{howToBecomeSegmentService.GetType().Name} is offline</h3>",
            };
            overviewBannerSegmentService.SegmentClientOptions = new OverviewBannerSegmentClientOptions
            {
                BaseAddress = baseAddress,
                Endpoint    = endpoint,
                OfflineHtml = $"<h3>{overviewBannerSegmentService.GetType().Name} is offline</h3>",
            };
            relatedCareersSegmentService.SegmentClientOptions = new RelatedCareersSegmentClientOptions
            {
                BaseAddress = baseAddress,
                Endpoint    = endpoint,
                OfflineHtml = $"<h3>{relatedCareersSegmentService.GetType().Name} is offline</h3>",
            };
            whatItTakesSegmentService.SegmentClientOptions = new WhatItTakesSegmentClientOptions
            {
                BaseAddress = baseAddress,
                Endpoint    = endpoint,
                OfflineHtml = $"<h3>{whatItTakesSegmentService.GetType().Name} is offline</h3>",
            };
            whatYouWillDoSegmentService.SegmentClientOptions = new WhatYouWillDoSegmentClientOptions
            {
                BaseAddress = baseAddress,
                Endpoint    = endpoint,
                OfflineHtml = $"<h3>{whatYouWillDoSegmentService.GetType().Name} is offline</h3>",
            };
        }
 public SegmentService(
     ILogService logService,
     ISegmentRefreshService <OverviewBannerSegmentClientOptions> overviewBannerSegmentService,
     ISegmentRefreshService <HowToBecomeSegmentClientOptions> howToBecomeSegmentService,
     ISegmentRefreshService <WhatItTakesSegmentClientOptions> whatItTakesSegmentService,
     ISegmentRefreshService <WhatYouWillDoSegmentClientOptions> whatYouWillDoSegmentService,
     ISegmentRefreshService <CareerPathSegmentClientOptions> careerPathSegmentService,
     ISegmentRefreshService <CurrentOpportunitiesSegmentClientOptions> currentOpportunitiesSegmentService,
     ISegmentRefreshService <RelatedCareersSegmentClientOptions> relatedCareersSegmentService)
 {
     this.logService = logService;
     this.overviewBannerSegmentService       = overviewBannerSegmentService;
     this.howToBecomeSegmentService          = howToBecomeSegmentService;
     this.whatItTakesSegmentService          = whatItTakesSegmentService;
     this.whatYouWillDoSegmentService        = whatYouWillDoSegmentService;
     this.careerPathSegmentService           = careerPathSegmentService;
     this.currentOpportunitiesSegmentService = currentOpportunitiesSegmentService;
     this.relatedCareersSegmentService       = relatedCareersSegmentService;
 }
        private async Task <SegmentModel> GetSegmentDataAsync <T>(ISegmentRefreshService <T> segmentService, RefreshJobProfileSegment toRefresh)
            where T : SegmentClientOptions
        {
            var jsonResultTask = segmentService.GetJsonAsync(toRefresh.JobProfileId);
            var htmlResultTask = segmentService.GetMarkupAsync(toRefresh.JobProfileId);

            await Task.WhenAll(jsonResultTask, htmlResultTask).ConfigureAwait(false);

            return(new SegmentModel
            {
                Segment = toRefresh.Segment,
                RefreshedAt = DateTime.UtcNow,
                RefreshSequence = toRefresh.SequenceNumber,
                Markup = htmlResultTask?.IsCompletedSuccessfully == true && htmlResultTask.Result != null ? new HtmlString(htmlResultTask.Result) : HtmlString.Empty,
                Json = jsonResultTask?.IsCompletedSuccessfully == true ? jsonResultTask.Result : null,
                RefreshStatus = jsonResultTask?.IsCompletedSuccessfully == true &&
                                htmlResultTask?.IsCompletedSuccessfully == true
                    ? Data.Enums.RefreshStatus.Success
                    : Data.Enums.RefreshStatus.Failed,
            });
        }