public RobotControllerTests()
        {
            defaultAppRegistryDataService = A.Fake <IAppRegistryDataService>();
            defaultLogger             = A.Fake <ILogger <RobotController> >();
            defaultWebHostEnvironment = A.Fake <IWebHostEnvironment>();
            defaultBaseUrlService     = A.Fake <IBaseUrlService>();

            var appRegistrationModels = new List <AppRegistrationModel>
            {
                new AppRegistrationModel
                {
                    RobotsURL = new Uri("http://SomeRobotUrl.xyz", UriKind.Absolute),
                    IsOnline  = true,
                },
            };

            A.CallTo(() => defaultAppRegistryDataService.GetAppRegistrationModels()).Returns(appRegistrationModels);

            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>();
            A.CallTo(() => defaultShellRobotFileService.GetStaticFileText(A <string> .Ignored)).Returns("{Insertion}");

            defaultController = new RobotController(defaultAppRegistryDataService, defaultLogger, defaultWebHostEnvironment, defaultTokenRetriever, defaultApplicationRobotService, defaultShellRobotFileService, defaultBaseUrlService)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = defaultHttpContext,
                },
                Url = defaultUrlHelper,
            };
        }
Exemplo n.º 2
0
 public RobotController(
     IAppRegistryDataService appRegistryDataService,
     ILogger <RobotController> logger,
     IWebHostEnvironment webHostEnvironment,
     IBearerTokenRetriever bearerTokenRetriever,
     IApplicationRobotService applicationRobotService,
     IShellRobotFileService shellRobotFileService,
     IBaseUrlService baseUrlService)
 {
     this.appRegistryDataService = appRegistryDataService;
     this.logger                  = logger;
     this.webHostEnvironment      = webHostEnvironment;
     this.bearerTokenRetriever    = bearerTokenRetriever;
     this.applicationRobotService = applicationRobotService;
     this.shellRobotFileService   = shellRobotFileService;
     this.baseUrlService          = baseUrlService;
 }