Exemplo n.º 1
0
        public void ShouldGetRobotsCustom()
        {
            ContentResult expectedResult = new ContentResult()
            {
                StatusCode  = StatusCodes.Status200OK,
                ContentType = MediaTypeNames.Text.Plain,
                Content     = "Custom Content",
            };

            string key             = "robots.txt";
            string robotsContent   = expectedResult.Content;
            var    myConfiguration = new Dictionary <string, string>
            {
                { key, robotsContent },
            };
            var configuration = new ConfigurationBuilder()
                                .AddInMemoryCollection(myConfiguration)
                                .Build();

            RobotsController controller = new RobotsController(configuration);

            IActionResult actualResult = controller.Robots();

            Assert.IsType <ContentResult>(actualResult);
            Assert.True(actualResult.IsDeepEqual(expectedResult));
        }
Exemplo n.º 2
0
        public void ShouldGetRobotsTxtDefaultConfig()
        {
            ContentResult expectedResult = new ContentResult()
            {
                StatusCode  = StatusCodes.Status200OK,
                ContentType = MediaTypeNames.Text.Plain,
                Content     = RobotsController.DefaultRobotsContent,
            };

            var myConfiguration = new Dictionary <string, string>
            {
            };
            var configuration = new ConfigurationBuilder()
                                .AddInMemoryCollection(myConfiguration)
                                .Build();

            RobotsController controller = new RobotsController(configuration);

            IActionResult actualResult = controller.Robots();

            Assert.IsType <ContentResult>(actualResult);
            Assert.True(actualResult.IsDeepEqual(expectedResult));
        }
        public void ShouldGetRobotsTxtDefaultConfig()
        {
            ContentResult expectedResult = new ContentResult()
            {
                StatusCode  = StatusCodes.Status200OK,
                ContentType = MediaTypeNames.Text.Plain,
                Content     = string.Empty,
            };

            var myConfiguration = new Dictionary <string, string>
            {
            };
            var configuration = new ConfigurationBuilder()
                                .AddInMemoryCollection(myConfiguration)
                                .Build();

            RobotsController controller = new RobotsController(configuration);

            ContentResult actualResult = (ContentResult)controller.Robots();

            Assert.Equal(actualResult.StatusCode, expectedResult.StatusCode);
            Assert.NotEmpty(actualResult.Content);
        }