Exemplo n.º 1
0
 public ApplicationController(
     IMapper <ApplicationModel, PageViewModel> mapper,
     ILogger <ApplicationController> logger,
     IApplicationService applicationService,
     IVersionedFiles versionedFiles,
     IConfiguration configuration,
     IBaseUrlService baseUrlService,
     INeo4JService neo4JService)
 {
     this.mapper             = mapper;
     this.logger             = logger;
     this.applicationService = applicationService;
     this.versionedFiles     = versionedFiles;
     this.configuration      = configuration;
     this.baseUrlService     = baseUrlService;
     this.neo4JService       = neo4JService;
 }
Exemplo n.º 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"))
                    },
                },
            };
        }