public void GetBindersFromAttributes_ReadsModelBinderAttributeFromBuddyClass() { // Act IModelBinder binder = ModelBinders.GetBinderFromAttributes(typeof(SampleModel), null); // Assert Assert.IsType <SampleModelBinder>(binder); }
public void GetBindersFromAttributes_ReadsModelBinderAttributeFromBuddyClass() { Action <Type> errorAction = (Type t) => { throw new InvalidOperationException(); }; // Act IModelBinder binder = ModelBinders.GetBinderFromAttributes(typeof(SampleModel), errorAction); // Assert Assert.IsType <SampleModelBinder>(binder); }
public void GetBindersFromAttributes_NullIfGetCustomAttributesReturnsNull() { // Arrange var provider = new Mock <ICustomAttributeProvider>(MockBehavior.Strict); bool inherit = true; provider.Setup(p => p.GetCustomAttributes(typeof(CustomModelBinderAttribute), inherit)).Returns((object[])null); Action <ICustomAttributeProvider> errorAction = (ICustomAttributeProvider t) => { throw new InvalidOperationException(); }; // Act IModelBinder binder = ModelBinders.GetBinderFromAttributes(provider.Object, errorAction); // Assert Assert.Null(binder); }