Exemplo n.º 1
0
        public void ShouldDeferToDefaultBinderIfNotSubcontroller()
        {
            var binder = new SubControllerBinder();
            var context = new ModelBindingContext {ValueProvider = valueProvider, ModelName = "foo", ModelType = typeof(string)};

            object value = binder.BindModel(new ControllerContext(), context);
            Assert.That(value, Is.EqualTo("bar"));
        }
        public void ShouldCreateSubcontroller()
        {
            var binder = new SubControllerBinder();
            var bindingContext = new ModelBindingContext { ModelMetadata   =  new ModelMetadata(new  EmptyModelMetadataProvider(), null, null, typeof(FooController), null)};

            object value = binder.BindModel(new ControllerContext(), bindingContext);
            Assert.That(value, Is.InstanceOf<FooController>());
        }
Exemplo n.º 3
0
        public void ShouldCreateSubcontroller()
        {
            var binder = new SubControllerBinder();
            var bindingContext = new ModelBindingContext {ModelType = typeof(FooController)};

            object value = binder.BindModel(new ControllerContext(), bindingContext);
            Assert.That(value, Is.InstanceOf<FooController>());
        }
        public void ShouldDeferToDefaultBinderIfNotSubcontroller()
        {
            var binder = new SubControllerBinder();
            var context = new ModelBindingContext
            {
                ModelMetadata = new ModelMetadata(new EmptyModelMetadataProvider(), null, null, typeof(string), null),
                ValueProvider = valueProvider,
                ModelName = "foo"
            };

            object value = binder.BindModel(new ControllerContext(), context);
            Assert.That(value, Is.EqualTo("bar"));
        }