public void SetDevice_InvalidContext_ReturnsNotNull()
        {
            var context = new DefaultHttpContext();

            Assert.NotNull(context.GetDevice());
            Assert.Equal("Desktop", context.GetDevice().ToString());
        }
Ejemplo n.º 2
0
    public void GetDevice_HttpContext_ReturnsExpected()
    {
        var device  = Device.Tablet;
        var context = new DefaultHttpContext();

        context.SetDevice(device);

        Assert.Equal(device, context.GetDevice());
        Assert.Equal(device, context.GetDevice());
    }
        public void GetDevice_HttpContext_ReturnsExpected()
        {
            var device = DeviceType.Tablet;
            //var preference = new UserPerference() { Resolver = device };
            var context = new DefaultHttpContext();

            context.SetDevice(device);

            Assert.Equal(device, context.GetDevice());
            Assert.Equal(device, context.GetDevice());
        }
        public void GetDevice_HttpContext_ReturnsExpected()
        {
            string device     = DeviceType.Tablet.ToString();
            var    preference = new UserPerference()
            {
                Resolver = device
            };
            var context = new DefaultHttpContext();

            context.SetDevice(preference);

            Assert.Same(preference, context.GetDevice());
            Assert.Same(preference.Resolver, context.GetDevice().Resolver);
        }
        public void SetDevice_InvalidContext_ReturnsNull()
        {
            var context = new DefaultHttpContext();

            // If the device is not found it just returns NULL. May be we can throw some exception here.
            Assert.Null(context.GetDevice());
        }
Ejemplo n.º 6
0
        public async void Invoke_HttpContext_IDeviceResolver_Success()
        {
            var context    = new DefaultHttpContext();
            var options    = Options.Create(new ResponsiveOptions());
            var middleware = new ResponsiveMiddleware(d => Task.Factory.StartNew(() => d), options);

            await middleware.Invoke(context, new DeviceResolver());

            Assert.Same(DeviceType.Tablet.ToString(), context.GetDevice().Device);
        }