Exemplo n.º 1
0
        public void ShouldThrow_WhenComponentIsNotIModelBinder()
        {
            var container = new WindsorContainer();
            container.AddComponent<object>("testmodelbinder");

            var binder = new WindsorModelBinder(container);
            binder.BindModel(new ControllerContext(),  _context);
        }
Exemplo n.º 2
0
        public void ShouldResolveTheCorrectBinder_WhenBinderExists()
        {
            IWindsorContainer container = new WindsorContainer();

            container.AddComponent<IModelBinder, TestModelBinder>("testmodelbinder");

            var binder = new WindsorModelBinder(container);

            var value = binder.BindModel(new ControllerContext(), _context);

            Assert.That(value, Is.EqualTo("TestResult"));
        }
Exemplo n.º 3
0
        public void ShouldFallbackToDefaultBinder_WhenBinderDoesNotExist()
        {
            var container = new WindsorContainer();
            var fallbackBinder = MockRepository.GenerateMock<IModelBinder>();
            fallbackBinder.Expect(b => b.BindModel(null,_context))
                .Return("MockedResult");

            var binder = new WindsorModelBinder(container, fallbackBinder);

            var value = binder.BindModel(new ControllerContext(), _context);

            Assert.That(value, Is.EqualTo("MockedResult"));
        }