Ejemplo n.º 1
0
        public async Task PostMarkupAsyncForOnlineApplication()
        {
            // Arrange
            var footerAndBodyRegions = new List <RegionModel> {
                defaultBodyRegion, defaultBodyFooterRegion
            };
            var fakeApplicationModel = new ApplicationModel {
                Path = defaultPathModel, Regions = footerAndBodyRegions
            };
            var pageModel = new PageViewModel();

            mapper.Map(fakeApplicationModel, pageModel);

            A.CallTo(() => contentRetriever.PostContent($"{RequestBaseUrl}/{fakeApplicationModel.Path.Path}/{Article}", defaultBodyRegion, defaultFormPostParams, RequestBaseUrl)).Returns(BodyRegionContent);

            // Act
            await applicationService.PostMarkupAsync(fakeApplicationModel, "index", Article, defaultFormPostParams, pageModel).ConfigureAwait(false);

            //Assert
            Assert.Equal(footerAndBodyRegions.Count, pageModel.PageRegionContentModels.Count);
            Assert.Equal(BodyRegionContent, pageModel.PageRegionContentModels.First(x => x.PageRegionType == PageRegion.Body).Content.Value);
            Assert.Equal(BodyFooterRegionContent, pageModel.PageRegionContentModels.First(x => x.PageRegionType == PageRegion.BodyFooter).Content.Value);

            A.CallTo(() => contentRetriever.PostContent($"{RequestBaseUrl}/{fakeApplicationModel.Path.Path}/{Article}", defaultBodyRegion, defaultFormPostParams, RequestBaseUrl)).MustHaveHappenedOnceExactly();
            A.CallTo(() => contentRetriever.GetContent($"{defaultBodyFooterRegion.RegionEndpoint}", defaultBodyFooterRegion, A <bool> .Ignored, RequestBaseUrl)).MustHaveHappenedOnceExactly();
        }
        public async Task PostMarkupAsyncForOnlineApplication()
        {
            // Arrange
            var footerAndBodyRegions = new List <RegionModel> {
                defaultHeadRegion, defaultBodyRegion, defaultBodyFooterRegion
            };
            var fakeApplicationModel = new ApplicationModel {
                AppRegistrationModel = defaultAppRegistrationModel, Article = Article
            };

            fakeApplicationModel.AppRegistrationModel.Regions = footerAndBodyRegions;

            var pageModel = new PageViewModel();
            await mapper.Map(fakeApplicationModel, pageModel);

            var postResponse = new PostResponseModel
            {
                Html = BodyRegionContent,
            };

            A.CallTo(() => contentRetriever.PostContent($"{defaultBodyRegion.RegionEndpoint}/{Article}", fakeApplicationModel.AppRegistrationModel.Path, defaultBodyRegion, defaultFormPostParams, RequestBaseUrl)).Returns(postResponse);
            A.CallTo(() => contentRetriever.GetContent($"{defaultBodyFooterRegion.RegionEndpoint}/{Article}", fakeApplicationModel.AppRegistrationModel.Path, defaultBodyFooterRegion, A <bool> .Ignored, RequestBaseUrl, A <IHeaderDictionary> .Ignored)).Returns(BodyFooterRegionContent);

            // Act
            await applicationService.PostMarkupAsync(fakeApplicationModel, defaultFormPostParams, pageModel, string.Empty, new HeaderDictionary());

            //Assert
            Assert.Equal(footerAndBodyRegions.Count, pageModel.PageRegionContentModels.Count);
            Assert.Equal(BodyRegionContent, pageModel.PageRegionContentModels.First(x => x.PageRegionType == PageRegion.Body).Content.Value);
            Assert.Equal(BodyFooterRegionContent, pageModel.PageRegionContentModels.First(x => x.PageRegionType == PageRegion.BodyFooter).Content.Value);

            A.CallTo(() => contentRetriever.PostContent($"{defaultBodyRegion.RegionEndpoint}/{Article}", fakeApplicationModel.AppRegistrationModel.Path, defaultBodyRegion, defaultFormPostParams, RequestBaseUrl)).MustHaveHappenedOnceExactly();
            A.CallTo(() => contentRetriever.GetContent($"{defaultBodyFooterRegion.RegionEndpoint}/{Article}", fakeApplicationModel.AppRegistrationModel.Path, defaultBodyFooterRegion, A <bool> .Ignored, RequestBaseUrl, A <IHeaderDictionary> .Ignored)).MustHaveHappenedOnceExactly();
        }
        private Task <string> GetPostMarkUpAsync(ApplicationModel application, IEnumerable <KeyValuePair <string, string> > formParameters)
        {
            //Get the body region
            var bodyRegion = application.AppRegistrationModel.Regions.FirstOrDefault(x => x.PageRegion == PageRegion.Body);

            if (bodyRegion == null || string.IsNullOrWhiteSpace(bodyRegion.RegionEndpoint))
            {
                return(Task.FromResult(string.Empty));
            }

            var url = FormatArticleUrl(bodyRegion.RegionEndpoint, application.Article, string.Empty);

            return(contentRetriever.PostContent(url, application.AppRegistrationModel.Path, bodyRegion, formParameters, RequestBaseUrl));
        }
Ejemplo n.º 4
0
        private Task <string> GetPostMarkUpAsync(ApplicationModel application, string article, IEnumerable <KeyValuePair <string, string> > formParameters)
        {
            //Get the body region
            var bodyRegion = application.Regions.FirstOrDefault(x => x.PageRegion == PageRegion.Body);

            if (bodyRegion == null || string.IsNullOrWhiteSpace(bodyRegion.RegionEndpoint))
            {
                return(Task.FromResult(string.Empty));
            }

            var uri = new Uri(bodyRegion.RegionEndpoint);
            var url = $"{uri.Scheme}://{uri.Authority}/{application.Path.Path}/{article}";

            return(contentRetriever.PostContent(url, bodyRegion, formParameters, RequestBaseUrl));
        }