Exemple #1
0
        public void ExpandLocations_ExpandsDirectories_MultipleLocations()
        {
            // Arrange
            var context = CreateContext(pageName: "/Customers/Edit");

            var locations = new string[]
            {
                "/Pages/{1}/{0}.cshtml",
                "/More/Paths/{1}/{0}.cshtml",
                "/Views/Shared/{0}.cshtml",
            };

            var expected = new string[]
            {
                "/Pages/Customers/{0}.cshtml",
                "/Pages/{0}.cshtml",
                "/More/Paths/Customers/{0}.cshtml",
                "/More/Paths/{0}.cshtml",
                "/Views/Shared/{0}.cshtml",
            };

            var expander = new PageViewLocationExpander();

            // Act
            var actual = expander.ExpandViewLocations(context, locations);

            // Assert
            Assert.Equal(expected, actual.ToArray());
        }
Exemple #2
0
        public void PopulateValues_DoesNothing()
        {
            // Arrange
            var context = CreateContext();

            var expander = new PageViewLocationExpander();

            // Act
            expander.PopulateValues(context);

            // Assert
            Assert.Empty(context.Values);
        }
Exemple #3
0
        public void ExpandLocations_NoOp_WhenLocationDoesNotContainPageToken()
        {
            // Arrange
            var context   = CreateContext(pageName: null);
            var locations = new string[]
            {
                "/ignore-me",
            };

            var expander = new PageViewLocationExpander();

            // Act
            var actual = expander.ExpandViewLocations(context, locations);

            // Assert
            Assert.Equal(locations, actual);
        }
        public void ExpandLocations_ExpandsAreaPaths(string pageName, string[] expected)
        {
            // Arrange
            var context   = CreateContext(pageName: pageName);
            var locations = new[]
            {
                "/Areas/{2}/Pages/{1}/{0}.cshtml",
            };

            var expander = new PageViewLocationExpander();

            // Act
            var actual = expander.ExpandViewLocations(context, locations);

            // Assert
            Assert.Equal(expected, actual.ToArray());
        }
Exemple #5
0
        public void ExpandLocations_ExpandsDirectories_WhenLocationContainsPage(
            string pageName,
            string[] expected)
        {
            // Arrange
            var context = CreateContext(pageName: pageName);

            var locations = new string[]
            {
                "/{1}/{0}.cshtml",
            };

            var expander = new PageViewLocationExpander();

            // Act
            var actual = expander.ExpandViewLocations(context, locations);

            // Assert
            Assert.Equal(expected, actual.ToArray());
        }
Exemple #6
0
        public void ExpandLocations_NoOp_ForNonPageWithPageName()
        {
            // Verifies the fix for https://github.com/aspnet/Mvc/issues/6660. This ensures that when PageViewLocationExpander is called
            // from a non-Razor Page with a route value for "
            // Arrange
            var context = CreateContext(pageName: "test");

            context.ActionContext.ActionDescriptor = new ControllerActionDescriptor();
            var locations = new string[]
            {
                "/ignore-me",
            };

            var expander = new PageViewLocationExpander();

            // Act
            var actual = expander.ExpandViewLocations(context, locations);

            // Assert
            Assert.Equal(locations, actual);
        }