Example #1
0
        public void ExpandViewLocations_SpecificLocale(
            LanguageViewLocationExpanderFormat format,
            IEnumerable <string> viewLocations,
            IEnumerable <string> expectedViewLocations)
        {
            // Arrange
            var viewLocationExpanderContext = new ViewLocationExpanderContext(
                new ActionContext(),
                "testView",
                "test-controller",
                "",
                false);
            var languageViewLocationExpander = new LanguageViewLocationExpander(format);

            viewLocationExpanderContext.Values             = new Dictionary <string, string>();
            viewLocationExpanderContext.Values["language"] = "en-GB";

            // Act
            var expandedViewLocations = languageViewLocationExpander.ExpandViewLocations(
                viewLocationExpanderContext,
                viewLocations);

            // Assert
            Assert.Equal(expectedViewLocations, expandedViewLocations);
        }
        public void ExpandViewLocations_NullContextValue(IEnumerable <string> viewLocations)
        {
            // Arrange
            var viewLocationExpanderContext  = new ViewLocationExpanderContext(new ActionContext(), "testView", false);
            var languageViewLocationExpander = new LanguageViewLocationExpander();

            viewLocationExpanderContext.Values = new Dictionary <string, string>();

            // Act
            var expandedViewLocations = languageViewLocationExpander.ExpandViewLocations(
                viewLocationExpanderContext,
                viewLocations);

            // Assert
            Assert.Equal(viewLocations, expandedViewLocations);
        }
        public void ExpandViewLocations_IncorrectLocaleContextValue(IEnumerable <string> viewLocations)
        {
            // Arrange
            var viewLocationExpanderContext  = new ViewLocationExpanderContext(new ActionContext(), "testView", false);
            var languageViewLocationExpander = new LanguageViewLocationExpander();

            viewLocationExpanderContext.Values             = new Dictionary <string, string>();
            viewLocationExpanderContext.Values["language"] = "!-invalid-culture-!";

            // Act
            var expandedViewLocations = languageViewLocationExpander.ExpandViewLocations(
                viewLocationExpanderContext,
                viewLocations);

            // Assert
            Assert.Equal(viewLocations, expandedViewLocations);
        }
        public void ExpandViewLocations_IncorrectLocaleContextValue(IEnumerable<string> viewLocations)
        {
            // Arrange
            var viewLocationExpanderContext = new ViewLocationExpanderContext(new ActionContext(), "testView", false);
            var languageViewLocationExpander = new LanguageViewLocationExpander();
            viewLocationExpanderContext.Values = new Dictionary<string, string>();
            viewLocationExpanderContext.Values["language"] = "!-invalid-culture-!";

            // Act
            var expandedViewLocations = languageViewLocationExpander.ExpandViewLocations(
                viewLocationExpanderContext,
                viewLocations);

            // Assert
            Assert.Equal(viewLocations, expandedViewLocations);
        }
        public void ExpandViewLocations_NullContextValue(IEnumerable<string> viewLocations)
        {
            // Arrange
            var viewLocationExpanderContext = new ViewLocationExpanderContext(new ActionContext(), "testView", false);
            var languageViewLocationExpander = new LanguageViewLocationExpander();
            viewLocationExpanderContext.Values = new Dictionary<string, string>();

            // Act
            var expandedViewLocations = languageViewLocationExpander.ExpandViewLocations(
                viewLocationExpanderContext,
                viewLocations);

            // Assert
            Assert.Equal(viewLocations, expandedViewLocations);
        }
        public void ExpandViewLocations_SpecificLocale(
            LanguageViewLocationExpanderFormat format,
            IEnumerable<string> viewLocations,
            IEnumerable<string> expectedViewLocations)
        {
            // Arrange
            var viewLocationExpanderContext = new ViewLocationExpanderContext(new ActionContext(),"testView", false);
            var languageViewLocationExpander = new LanguageViewLocationExpander(format);
            viewLocationExpanderContext.Values = new Dictionary<string, string>();
            viewLocationExpanderContext.Values["language"] = "en-GB";

            // Act
            var expandedViewLocations = languageViewLocationExpander.ExpandViewLocations(
                viewLocationExpanderContext,
                viewLocations);

            // Assert
            Assert.Equal(expectedViewLocations, expandedViewLocations);
        }