Beispiel #1
0
        public void Create_ForSupportedType_ReturnsBinder()
        {
            // Arrange
            var provider = new ComplexObjectModelBinderProvider();

            var context = new TestModelBinderProviderContext(typeof(Person));

            context.OnCreatingBinder(m =>
            {
                if (m.ModelType == typeof(int) || m.ModelType == typeof(string))
                {
                    return(Mock.Of <IModelBinder>());
                }
                else
                {
                    Assert.False(true, "Not the right model type");
                    return(null);
                }
            });

            // Act
            var result = provider.GetBinder(context);

            // Assert
            Assert.IsType <ComplexObjectModelBinder>(result);
        }
Beispiel #2
0
        public void Create_ForNonComplexType_ReturnsNull(Type modelType)
        {
            // Arrange
            var provider = new ComplexObjectModelBinderProvider();

            var context = new TestModelBinderProviderContext(modelType);

            // Act
            var result = provider.GetBinder(context);

            // Assert
            Assert.Null(result);
        }
 public BodyOrDefaultModelBinderProvider(BodyModelBinderProvider bodyModelBinderProvider, ComplexDataModelBinderProvider complexDataModelBinderProvider)
 {
     _bodyModelBinderProvider        = bodyModelBinderProvider;
     _complexDataModelBinderProvider = complexDataModelBinderProvider;
 }