public ContentRetriever(IUriSpecifcHttpClientFactory httpClientFactory, ILogger <ContentRetriever> logger, IAppRegistryDataService appRegistryDataService, IHttpResponseMessageHandler responseHandler, MarkupMessages markupMessages, IMemoryCache memoryCache, IOptions <PassOnHeaderSettings> headerSettings)
 {
     this.httpClientFactory      = httpClientFactory;
     this.logger                 = logger;
     this.appRegistryDataService = appRegistryDataService;
     this.responseHandler        = responseHandler;
     this.markupMessages         = markupMessages;
     this.memoryCache            = memoryCache;
     this.headerSettings         = headerSettings?.Value ?? new PassOnHeaderSettings();
 }
Exemple #2
0
        public ContentRetrieverTests()
        {
            httpResponse = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(DummyChildAppContent),
            };

            fakeHttpRequestSender = A.Fake <IFakeHttpRequestSender>();
            A.CallTo(() => fakeHttpRequestSender.Send(A <HttpRequestMessage> .Ignored)).Returns(httpResponse);

            fakeHttpMessageHandler = new FakeHttpMessageHandler(fakeHttpRequestSender);

            httpClientFactory = A.Fake <IUriSpecifcHttpClientFactory>();
            httpClient        = new HttpClient(fakeHttpMessageHandler)
            {
                BaseAddress = new Uri("http://SomeRegionBaseAddress"),
            };

            A.CallTo(() => httpClientFactory.GetClientForRegionEndpoint(A <string> .Ignored)).Returns(httpClient);

            defaultFormPostParams = new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("formParam1", "test value")
            };

            logger = A.Fake <ILogger <ContentRetriever> >();
            appRegistryDataService     = A.Fake <IAppRegistryDataService>();
            httpResponseMessageHandler = A.Fake <IHttpResponseMessageHandler>();
            markupMessages             = new MarkupMessages
            {
                AppOfflineHtml    = "<h3>App offline</h3>",
                RegionOfflineHtml = new Dictionary <PageRegion, string>
                {
                    {
                        PageRegion.Head, "<h3>Head Region is offline</h3>"
                    },
                    {
                        PageRegion.Breadcrumb, "<h3>Breadcrumb Region is offline</h3>"
                    },
                    {
                        PageRegion.BodyTop, "<h3>BodyTop Region is offline</h3>"
                    },
                    {
                        PageRegion.Body, "<h3>Body Region is offline</h3>"
                    },
                    {
                        PageRegion.SidebarRight, "<h3>SidebarRight Region is offline</h3>"
                    },
                    {
                        PageRegion.SidebarLeft, "<h3>SidebarLeft Region is offline</h3>"
                    },
                    {
                        PageRegion.BodyFooter, "<h3>BodyFooter Region is offline</h3>"
                    },
                    {
                        PageRegion.HeroBanner, "<h3>HeroBanner Region is offline</h3>"
                    },
                },
            };

            memoryCache    = new MemoryCache(Options.Create(new MemoryCacheOptions()));
            defaultService = new ContentRetriever(httpClientFactory, logger, appRegistryDataService, httpResponseMessageHandler, markupMessages, memoryCache, passOnHeaderSettings);
        }