Пример #1
0
    public ResponsiveViewLocationExpander(ResponsiveViewLocationFormat format)
    {
        if (!Enum.IsDefined(typeof(ResponsiveViewLocationFormat), (int)format))
        {
            throw new InvalidEnumArgumentException(nameof(format));
        }

        _format = format;
    }
Пример #2
0
        private static IResponsiveCoreBuilder AddViewLocation(
            this IResponsiveCoreBuilder builder,
            ResponsiveViewLocationFormat format)
        {
            builder.Services.Configure <RazorViewEngineOptions>(
                options =>
            {
                options.ViewLocationExpanders.Add(new ResponsiveViewLocationExpander(format));
            });

            return(builder);
        }
Пример #3
0
        public void ExpandViewLocations_ViewLocationExpanderContext_IEnumerable_ReturnsExpected(
            ResponsiveViewLocationFormat format,
            IEnumerable <string> viewLocations,
            IEnumerable <string> expectedViewLocations)
        {
            var context          = SetupViewLocationExpanderContext();
            var locationExpander = new ResponsiveViewLocationExpander(format);

            locationExpander.PopulateValues(context);
            var resultLocations = locationExpander.ExpandViewLocations(context, viewLocations).ToList();

            Assert.Equal(expectedViewLocations, resultLocations.ToList());
        }