public void GetBinder() { // Arrange Type binderType = typeof(GoodConverter); ModelBinderAttribute attr = new ModelBinderAttribute(binderType); // Act IModelBinder binder = attr.GetBinder(); // Assert Assert.IsInstanceOfType(binder, binderType); }
public void GetBinderWithBadConstructorThrows() { // Arrange Type binderType = typeof(BadConverter); ModelBinderAttribute attr = new ModelBinderAttribute(binderType); // Act & Assert ExceptionHelper.ExpectInvalidOperationException( delegate { attr.GetBinder(); }, "An error occurred when trying to create the IModelBinder 'System.Web.Mvc.Test.ModelBinderAttributeTest+BadConverter'. Make sure that the binder has a public parameterless constructor."); }
public void GetBinderWithBadConstructorThrows() { // Arrange Type binderType = typeof(BadConverter); ModelBinderAttribute attr = new ModelBinderAttribute(binderType); // Act & Assert ExceptionHelper.ExpectInvalidOperationException( delegate { attr.GetBinder(); }, "There was an error creating the IModelBinder 'System.Web.Mvc.Test.ModelBinderAttributeTest+BadConverter'." + " Check that it has a public parameterless constructor."); }