public void ExpandViewLocations_ViewLocationExpanderContext_Null_ThrowsArgumentNullException()
    {
        var locationExpander = new ResponsiveViewLocationExpander(ResponsiveViewLocationFormat.Suffix);

        Assert.Throws <ArgumentNullException>(() =>
                                              locationExpander.ExpandViewLocations(SetupViewLocationExpanderContext(Device.Tablet), null !));
    }
    public void ExpandViewLocations_ViewLocationExpanderContext_IEnumerable_ReturnsExpected(ResponsiveViewLocationFormat format, Device deviceType, IEnumerable <string> viewLocations, IEnumerable <string> expectedViewLocations)
    {
        var context          = SetupViewLocationExpanderContext(deviceType);
        var locationExpander = new ResponsiveViewLocationExpander(format);

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

        Assert.Equal(expectedViewLocations, resultLocations.ToArray());
    }
예제 #3
0
        [Fact]//(Skip = "Fails with NullReferenceExeption because context.Values is not set to instance of an object.")]
        public void PopulateValues_ViewLocationExpanderContext_Success()
        {
            string deviceKey        = "device"; // May this one can be public in ResponsiveViewLocationExpander.cs.
            var    context          = SetupViewLocationExpanderContext();
            var    locationExpander = new ResponsiveViewLocationExpander();

            locationExpander.PopulateValues(context);

            Assert.NotEqual(0, context.Values.Count);
            Assert.Same(context.ActionContext.HttpContext.GetDevice().Device, context.Values[deviceKey]);
        }
    public void ExpandViewLocations_NoDevice_ReturnsExpected()
    {
        var context       = SetupViewLocationExpanderContext(Device.Tablet);
        var viewLocations = new List <string> {
            "/Views/{1}/{0}.cshtml", "/Views/Shared/{0}.cshtml"
        };
        var locationExpander = new ResponsiveViewLocationExpander(ResponsiveViewLocationFormat.Suffix);
        var resultLocations  = locationExpander.ExpandViewLocations(context, viewLocations);

        Assert.Equal(viewLocations, resultLocations);
    }
예제 #5
0
        public void ExpandViewLocations_NoDevice_ReturnsExpected()
        {
            var context       = SetupViewLocationExpanderContext();
            var viewLocations = new List <string>()
            {
                "{0} location1", "{0} location2"
            };
            var locationExpander = new ResponsiveViewLocationExpander();
            var resultLocations  = locationExpander.ExpandViewLocations(context, viewLocations);

            Assert.Equal(viewLocations.Count, resultLocations.ToList().Count);
        }
예제 #6
0
        public void ExpandViewLocations_ViewLocationExpanderContext_IEnumerable_ReturnsExpected()
        {
            var context       = SetupViewLocationExpanderContext();
            var viewLocations = new List <string>()
            {
                "{0} location1", "{0} location2"
            };
            var locationExpander = new ResponsiveViewLocationExpander();

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

            Assert.True(viewLocations.Count < resultLocations.ToList().Count);
        }
예제 #7
0
        public void ExpandViewLocations_ViewLocationExpanderContext_Null_ThrowsArgumentNullException()
        {
            var locationExpander = new ResponsiveViewLocationExpander();

            Assert.Throws <ArgumentNullException>(() => locationExpander.ExpandViewLocations(SetupViewLocationExpanderContext(), null));
        }
예제 #8
0
        public void ExpandViewLocations_Null_IEnumerable_ThrowsArgumentNullException()
        {
            var locationExpander = new ResponsiveViewLocationExpander();

            Assert.Throws <ArgumentNullException>(() => locationExpander.ExpandViewLocations(null, new List <string>()));
        }
예제 #9
0
        public void PopulateValues_Null_ThrowsArgumentNullException()
        {
            var locationExpander = new ResponsiveViewLocationExpander();

            Assert.Throws <ArgumentNullException>(() => locationExpander.PopulateValues(null));
        }
예제 #10
0
 public void Ctor_ResponsiveViewLocationFormat_Success()
 {
     var locationExpander = new ResponsiveViewLocationExpander(ResponsiveViewLocationFormat.Subfolder);
     // May be we can make "_format" public so we can test the value is set properly.
 }
예제 #11
0
 public void Ctor_Default_Success()
 {
     var locationExpander = new ResponsiveViewLocationExpander();
     // May be we can make "_format" public so we can test the default value is set properly.
 }
    public void Ctor_ResponsiveViewLocationFormat_Success()
    {
        var locationExpander = new ResponsiveViewLocationExpander(ResponsiveViewLocationFormat.Subfolder);

        Assert.NotNull(locationExpander);
    }
예제 #13
0
 public void Ctor_Default_Success()
 {
     var locationExpander = new ResponsiveViewLocationExpander();
 }