コード例 #1
0
        public ApplicationControllerTests()
        {
            defaultMapper             = new ApplicationToPageModelMapper();
            defaultLogger             = A.Fake <ILogger <ApplicationController> >();
            defaultApplicationService = A.Fake <IApplicationService>();
            defaultVersionedFiles     = A.Fake <IVersionedFiles>();
            defaultConfiguration      = A.Fake <IConfiguration>();
            defaultBaseUrlService     = A.Fake <IBaseUrlService>();

            defaultApplicationModel = new ApplicationModel
            {
                Path = new PathModel {
                    Path = ChildAppPath
                },
                Regions = new List <RegionModel>
                {
                    new RegionModel
                    {
                        Path           = ChildAppPath,
                        IsHealthy      = true,
                        PageRegion     = PageRegion.Body,
                        RegionEndpoint = "http://childApp/bodyRegion",
                    },
                },
            };
            A.CallTo(() => defaultApplicationService.GetApplicationAsync(ChildAppPath)).Returns(defaultApplicationModel);

            var fakeHttpContext = new DefaultHttpContext {
                Request = { QueryString = QueryString.Create("test", "testvalue") }
            };

            defaultPostRequestViewModel = new ActionPostRequestModel
            {
                Path           = ChildAppPath,
                FormCollection = new FormCollection(new Dictionary <string, StringValues>
                {
                    { "someKey", "someFormValue" },
                }),
            };

            defaultGetController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = fakeHttpContext,
                },
            };

            defaultPostController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                        Request = { Method = "POST" },
                    },
                },
            };
        }
コード例 #2
0
        public ApplicationControllerTests()
        {
            defaultAppRegistryDataService = A.Fake <IAppRegistryDataService>();
            defaultMapper             = new ApplicationToPageModelMapper(defaultAppRegistryDataService);
            defaultLogger             = A.Fake <ILogger <ApplicationController> >();
            defaultApplicationService = A.Fake <IApplicationService>();
            defaultVersionedFiles     = A.Fake <IVersionedFiles>();
            defaultConfiguration      = A.Fake <IConfiguration>();
            defaultBaseUrlService     = A.Fake <IBaseUrlService>();
            neo4JService = A.Fake <INeo4JService>();

            defaultApplicationModel = new ApplicationModel
            {
                AppRegistrationModel = new AppRegistrationModel
                {
                    Path    = ChildAppPath,
                    Regions = new List <RegionModel>
                    {
                        new RegionModel
                        {
                            IsHealthy      = true,
                            PageRegion     = PageRegion.Body,
                            RegionEndpoint = "http://childApp/bodyRegion",
                        },
                    },
                },
            };
            defaultPostRequestViewModel = new ActionPostRequestModel
            {
                Path           = ChildAppPath,
                Data           = ChildAppData,
                FormCollection = new FormCollection(new Dictionary <string, StringValues>
                {
                    { "someKey", "someFormValue" },
                }),
            };
            childAppActionGetRequestModel = defaultPostRequestViewModel;
            A.CallTo(() => defaultApplicationService.GetApplicationAsync(childAppActionGetRequestModel)).Returns(defaultApplicationModel);

            var fakeHttpContext = new DefaultHttpContext {
                Request = { QueryString = QueryString.Create("test", "testvalue") }
            };

            defaultGetController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = fakeHttpContext,
                },
            };

            defaultPostController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                        Request = { Method = "POST" },
                    },
                },
            };

            bearerTokenController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext {
                        User = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim> {
                            new Claim("bearer", "test")
                        }, "mock"))
                    },
                },
            };

            postBearerTokenController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext {
                        User = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim> {
                            new Claim("bearer", "test")
                        }, "mock"))
                    },
                },
            };
        }