public async Task RobotsControllerRemovesUserAgentSegmentFromRobotText(string segmentToSkip) { var applicationRobotService = A.Fake <IApplicationRobotService>(); A.CallTo(() => applicationRobotService.GetAsync(A <ApplicationRobotModel> .Ignored)).Returns($"{segmentToSkip}: Dummy text value"); var robotController = new RobotController(defaultAppRegistryDataService, defaultLogger, defaultWebHostEnvironment, defaultTokenRetriever, applicationRobotService, defaultShellRobotFileService, defaultBaseUrlService) { ControllerContext = new ControllerContext { HttpContext = defaultHttpContext, }, Url = defaultUrlHelper, }; var result = await robotController.Robot().ConfigureAwait(false); var resultLines = result.Content.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); Assert.DoesNotContain(segmentToSkip, resultLines.ToList()); robotController.Dispose(); }
public async Task RobotsControllerReplacesApplicationBaseUrlWithShellUrl() { const string appBaseUrl = "http://appBaseUrl"; var appRegistrationModels = new List <AppRegistrationModel> { new AppRegistrationModel { RobotsURL = new Uri(appBaseUrl, UriKind.Absolute), IsOnline = true, }, }; var shellAppRegistryDataService = A.Fake <IAppRegistryDataService>(); A.CallTo(() => shellAppRegistryDataService.GetAppRegistrationModels()).Returns(appRegistrationModels); var robotService = A.Fake <IApplicationRobotService>(); A.CallTo(() => robotService.GetAsync(A <ApplicationRobotModel> .Ignored)).Returns($"RetrievedValue: {appBaseUrl}/test"); var robotController = new RobotController(shellAppRegistryDataService, defaultLogger, defaultWebHostEnvironment, defaultTokenRetriever, robotService, defaultShellRobotFileService, defaultBaseUrlService) { ControllerContext = new ControllerContext { HttpContext = defaultHttpContext, }, Url = defaultUrlHelper, }; var result = await robotController.Robot().ConfigureAwait(false); var resultLines = result.Content.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); Assert.DoesNotContain("http://appBaseUrl", resultLines.ToList()); robotController.Dispose(); }