Esempio n. 1
0
        public SitemapControllerTests()
        {
            defaultPathDataService = A.Fake <IPathDataService>();
            defaultLogger          = A.Fake <ILogger <SitemapController> >();
            defaultBaseUrlService  = A.Fake <IBaseUrlService>();

            var pathModels = new List <PathModel>
            {
                new PathModel
                {
                    SitemapURL = "http://SomeSitemapUrl.xyz",
                    IsOnline   = true,
                },
            };

            A.CallTo(() => defaultPathDataService.GetPaths()).Returns(pathModels);

            var user = A.Fake <ClaimsPrincipal>();

            A.CallTo(() => user.Identity.IsAuthenticated).Returns(true);

            defaultHttpContext = A.Fake <HttpContext>();
            defaultHttpContext.Request.Scheme = DummyScheme;
            defaultHttpContext.Request.Host   = new HostString(DummyHost);

            var fakeIdentity = new GenericIdentity("User");
            var principal    = new GenericPrincipal(fakeIdentity, null);

            A.CallTo(() => defaultHttpContext.User).Returns(principal);

            defaultUrlHelper = A.Fake <IUrlHelper>();
            A.CallTo(() => defaultUrlHelper.Action(A <UrlActionContext> .Ignored)).Returns(DummyHomeIndex);

            defaultTokenRetriever = A.Fake <IBearerTokenRetriever>();
            A.CallTo(() => defaultTokenRetriever.GetToken(A <HttpContext> .Ignored)).Returns("SomeToken");

            A.CallTo(() => defaultBaseUrlService.GetBaseUrl(A <HttpRequest> .Ignored, A <IUrlHelper> .Ignored))
            .Returns("http://SomeBaseUrl");

            defaultSitemapService = A.Fake <IApplicationSitemapService>();
            A.CallTo(() => defaultSitemapService.GetAsync(A <ApplicationSitemapModel> .Ignored))
            .Returns(Task.FromResult <IEnumerable <SitemapLocation> >(new List <SitemapLocation>()
            {
                new SitemapLocation
                {
                    Url      = "http://Sitemap.xml",
                    Priority = 1,
                },
            }));

            defaultController = new SitemapController(defaultPathDataService, defaultLogger, defaultTokenRetriever, defaultBaseUrlService, defaultSitemapService)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = defaultHttpContext,
                },
                Url = defaultUrlHelper,
            };
        }
Esempio n. 2
0
        public HealthControllerTests()
        {
            pathDataService          = A.Fake <IPathDataService>();
            regionService            = A.Fake <IRegionService>();
            logger                   = A.Fake <ILogger <HealthController> >();
            bearerTokenRetriever     = A.Fake <IBearerTokenRetriever>();
            applicationHealthService = A.Fake <IApplicationHealthService>();

            healthController = new HealthController(pathDataService, regionService, logger, bearerTokenRetriever, applicationHealthService);
        }
Esempio n. 3
0
        public RobotControllerTests()
        {
            defaultPathDataService    = A.Fake <IPathDataService>();
            defaultLogger             = A.Fake <ILogger <RobotController> >();
            defaultWebHostEnvironment = A.Fake <IWebHostEnvironment>();
            defaultBaseUrlService     = A.Fake <IBaseUrlService>();

            var pathModels = new List <PathModel>
            {
                new PathModel
                {
                    RobotsURL = "http://SomeRobotUrl.xyz",
                    IsOnline  = true,
                },
            };

            A.CallTo(() => defaultPathDataService.GetPaths()).Returns(pathModels);

            var user = A.Fake <ClaimsPrincipal>();

            A.CallTo(() => user.Identity.IsAuthenticated).Returns(true);

            defaultHttpContext = A.Fake <HttpContext>();
            defaultHttpContext.Request.Scheme = DummyScheme;
            defaultHttpContext.Request.Host   = new HostString(DummyHost);

            var fakeIdentity = new GenericIdentity("User");
            var principal    = new GenericPrincipal(fakeIdentity, null);

            A.CallTo(() => defaultHttpContext.User).Returns(principal);

            defaultUrlHelper = A.Fake <IUrlHelper>();
            A.CallTo(() => defaultUrlHelper.Content(A <string> .Ignored)).Returns("DummyUrl");
            A.CallTo(() => defaultUrlHelper.RouteUrl(A <UrlRouteContext> .Ignored)).Returns(DummySitemapUrl);

            defaultTokenRetriever = A.Fake <IBearerTokenRetriever>();
            A.CallTo(() => defaultTokenRetriever.GetToken(A <HttpContext> .Ignored)).Returns("SomeToken");

            defaultApplicationRobotService = A.Fake <IApplicationRobotService>();
            A.CallTo(() => defaultApplicationRobotService.GetAsync(A <ApplicationRobotModel> .Ignored)).Returns("RetrievedValue: SomeValue");

            defaultShellRobotFileService = A.Fake <IShellRobotFileService>();

            defaultController = new RobotController(defaultPathDataService, defaultLogger, defaultWebHostEnvironment, defaultTokenRetriever, defaultApplicationRobotService, defaultShellRobotFileService, defaultBaseUrlService)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = defaultHttpContext,
                },
                Url = defaultUrlHelper,
            };
        }
Esempio n. 4
0
 public SitemapController(
     IPathDataService pathDataService,
     ILogger <SitemapController> logger,
     IBearerTokenRetriever bearerTokenRetriever,
     IBaseUrlService baseUrlService,
     IApplicationSitemapService sitemapService)
 {
     this.pathDataService      = pathDataService;
     this.logger               = logger;
     this.bearerTokenRetriever = bearerTokenRetriever;
     this.baseUrlService       = baseUrlService;
     this.sitemapService       = sitemapService;
 }
Esempio n. 5
0
 public HealthController(
     IPathDataService pathDataService,
     IRegionService regionService,
     ILogger<HealthController> logger,
     IBearerTokenRetriever bearerTokenRetriever,
     IApplicationHealthService applicationHealthService)
 {
     this.pathDataService = pathDataService;
     this.regionService = regionService;
     this.logger = logger;
     this.bearerTokenRetriever = bearerTokenRetriever;
     this.applicationHealthService = applicationHealthService;
 }
Esempio n. 6
0
 public ApplicationService(
     IPathDataService pathDataService,
     IRegionService regionService,
     IContentRetriever contentRetriever,
     IContentProcessorService contentProcessorService,
     ITaskHelper taskHelper)
 {
     this.pathDataService         = pathDataService;
     this.regionService           = regionService;
     this.contentRetriever        = contentRetriever;
     this.contentProcessorService = contentProcessorService;
     this.taskHelper = taskHelper;
 }
Esempio n. 7
0
 public RobotController(
     IPathDataService pathDataService,
     ILogger <RobotController> logger,
     IWebHostEnvironment webHostEnvironment,
     IBearerTokenRetriever bearerTokenRetriever,
     IApplicationRobotService applicationRobotService,
     IShellRobotFileService shellRobotFileService,
     IBaseUrlService baseUrlService)
 {
     this.pathDataService         = pathDataService;
     this.logger                  = logger;
     this.webHostEnvironment      = webHostEnvironment;
     this.bearerTokenRetriever    = bearerTokenRetriever;
     this.applicationRobotService = applicationRobotService;
     this.shellRobotFileService   = shellRobotFileService;
     this.baseUrlService          = baseUrlService;
 }
Esempio n. 8
0
        public ApplicationServiceTests()
        {
            mapper = new ApplicationToPageModelMapper();

            pathDataService  = A.Fake <IPathDataService>();
            regionService    = A.Fake <IRegionService>();
            contentRetriever = A.Fake <IContentRetriever>();
            contentProcessor = A.Fake <IContentProcessorService>();

            defaultPathModel = new PathModel {
                Path = Path, TopNavigationOrder = 1, IsOnline = true
            };

            var headRegionEndPoint   = $"{RequestBaseUrl}/headRegionEndpoint";
            var bodyRegionEndPoint   = $"{RequestBaseUrl}/bodyRegionEndpoint";
            var footerRegionEndPoint = $"{RequestBaseUrl}/footerRegionEndpoint";

            defaultHeadRegion = new RegionModel {
                PageRegion = PageRegion.Head, RegionEndpoint = headRegionEndPoint, IsHealthy = true, OfflineHTML = OfflineHTML
            };
            defaultBodyRegion = new RegionModel {
                PageRegion = PageRegion.Body, RegionEndpoint = bodyRegionEndPoint, IsHealthy = true, OfflineHTML = OfflineHTML
            };
            defaultBodyFooterRegion = new RegionModel {
                PageRegion = PageRegion.BodyFooter, RegionEndpoint = footerRegionEndPoint, IsHealthy = true, OfflineHTML = OfflineHTML
            };
            defaultRegions = new List <RegionModel>
            {
                defaultHeadRegion,
                defaultBodyRegion,
                defaultBodyFooterRegion,
            };

            defaultPageViewModel = new PageViewModel
            {
                PageRegionContentModels = new List <PageRegionContentModel>
                {
                    new PageRegionContentModel
                    {
                        PageRegionType = PageRegion.Body,
                    },
                },
            };

            defaultApplicationModel = new ApplicationModel {
                Path = defaultPathModel, Regions = defaultRegions
            };
            offlineApplicationModel = new ApplicationModel {
                Path = new PathModel {
                    IsOnline = false, OfflineHtml = OfflineHTML
                }
            };

            A.CallTo(() => pathDataService.GetPath(Path)).Returns(defaultPathModel);
            A.CallTo(() => regionService.GetRegions(A <string> .Ignored)).Returns(defaultRegions);
            A.CallTo(() => contentRetriever.GetContent($"{defaultHeadRegion.RegionEndpoint}/index", defaultHeadRegion, A <bool> .Ignored, RequestBaseUrl)).Returns(HeadRegionContent);
            A.CallTo(() => contentRetriever.GetContent($"{defaultBodyRegion.RegionEndpoint}/index", defaultBodyRegion, A <bool> .Ignored, RequestBaseUrl)).Returns(BodyRegionContent);
            A.CallTo(() => contentRetriever.GetContent($"{defaultBodyFooterRegion.RegionEndpoint}", defaultBodyFooterRegion, A <bool> .Ignored, RequestBaseUrl)).Returns(BodyFooterRegionContent);
            A.CallTo(() => contentRetriever.GetContent($"{defaultBodyFooterRegion.RegionEndpoint}/index", defaultBodyFooterRegion, A <bool> .Ignored, RequestBaseUrl)).Returns(BodyFooterRegionContent);

            A.CallTo(() => contentProcessor.Process(HeadRegionContent, A <string> .Ignored, A <string> .Ignored)).Returns(HeadRegionContent);
            A.CallTo(() => contentProcessor.Process(BodyRegionContent, A <string> .Ignored, A <string> .Ignored)).Returns(BodyRegionContent);
            A.CallTo(() => contentProcessor.Process(BodyFooterRegionContent, A <string> .Ignored, A <string> .Ignored)).Returns(BodyFooterRegionContent);

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

            taskHelper = A.Fake <ITaskHelper>();
            A.CallTo(() => taskHelper.TaskCompletedSuccessfully(A <Task> .Ignored)).Returns(true);

            applicationService = new ApplicationService(pathDataService, regionService, contentRetriever, contentProcessor, taskHelper)
            {
                RequestBaseUrl = RequestBaseUrl
            };
        }
Esempio n. 9
0
 public ListPathsViewComponent(IPathDataService pathDataService)
 {
     this.pathDataService = pathDataService;
 }
Esempio n. 10
0
 public ShowHelpLinksViewComponent(ILogger <ShowHelpLinksViewComponent> logger, IPathDataService pathDataService)
 {
     this.logger          = logger;
     this.pathDataService = pathDataService;
 }