public async Task RobotsControllerWritesShellRobotsTextAtFirstPositionWhenFileExists() { const string SomeShellFileText = "SomeFileText"; A.CallTo(() => defaultShellRobotFileService.GetStaticFileText(A <string> .Ignored)).Returns(SomeShellFileText); var result = await defaultController.Robot(); var resultLines = result.Content.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); Assert.Equal(resultLines[0], SomeShellFileText); }
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, }; }
private Task <string> GetStaticContent() { return(shellRobotFileService.GetStaticFileText(webHostEnvironment.WebRootPath)); }