public void ShouldThrow_WhenComponentIsNotIModelBinder() { var container = new WindsorContainer(); container.AddComponent<object>("testmodelbinder"); var binder = new WindsorModelBinder(container); binder.BindModel(new ControllerContext(), _context); }
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")); }
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")); }