public void Create_ForNonSupportedTypes_ReturnsNull(Type modelType) { // Arrange var provider = new CollectionModelBinderProvider(); var context = new TestModelBinderProviderContext(modelType); // Act var result = provider.GetBinder(context); // Assert Assert.Null(result); }
public void Create_ForNonSupportedTypes_ReturnsNull(Type modelType) { // Arrange var provider = new CollectionModelBinderProvider(); var context = new TestModelBinderProviderContext(modelType); // Act var result = provider.GetBinder(context); // Assert Assert.Null(result); }
public void Create_ForNonICollectionTypes_ReadOnlyProperty_ReturnsNull(string propertyName) { // Arrange var provider = new CollectionModelBinderProvider(); var metadataProvider = TestModelBinderProviderContext.CachedMetadataProvider; var metadata = metadataProvider.GetMetadataForProperty(typeof(ReadOnlyProperties), propertyName); Assert.NotNull(metadata); Assert.True(metadata.IsReadOnly); var context = new TestModelBinderProviderContext(metadata, bindingInfo: null); // Act var result = provider.GetBinder(context); // Assert Assert.Null(result); }
public void Create_ForNonICollectionTypes_ReadOnlyProperty_ReturnsNull(string propertyName) { // Arrange var provider = new CollectionModelBinderProvider(); var metadataProvider = TestModelBinderProviderContext.CachedMetadataProvider; var metadata = metadataProvider.GetMetadataForProperty(typeof(ReadOnlyProperties), propertyName); Assert.NotNull(metadata); Assert.True(metadata.IsReadOnly); var context = new TestModelBinderProviderContext(metadata, bindingInfo: null); // Act var result = provider.GetBinder(context); // Assert Assert.Null(result); }
public void Create_ForSupportedType_ReturnsBinder() { // Arrange var provider = new CollectionModelBinderProvider(); var context = new TestModelBinderProviderContext(typeof(List <int>)); context.OnCreatingBinder(m => { Assert.Equal(typeof(int), m.ModelType); return(Mock.Of <IModelBinder>()); }); // Act var result = provider.GetBinder(context); // Assert var binder = Assert.IsType <CollectionModelBinder <int> >(result); Assert.True(binder.AllowValidatingTopLevelNodes); }
public void Create_ForSupportedTypes_ReturnsBinder(Type modelType) { // Arrange var provider = new CollectionModelBinderProvider(); var context = new TestModelBinderProviderContext(modelType); Type elementType = null; context.OnCreatingBinder(m => { Assert.Equal(typeof(int), m.ModelType); elementType = m.ModelType; return(Mock.Of <IModelBinder>()); }); // Act var result = provider.GetBinder(context); // Assert Assert.NotNull(elementType); Assert.IsType <CollectionModelBinder <int> >(result); }
public void Create_ForSupportedTypes_ReturnsBinder(Type modelType) { // Arrange var provider = new CollectionModelBinderProvider(); var context = new TestModelBinderProviderContext(modelType); Type elementType = null; context.OnCreatingBinder(m => { Assert.Equal(typeof(int), m.ModelType); elementType = m.ModelType; return Mock.Of<IModelBinder>(); }); // Act var result = provider.GetBinder(context); // Assert Assert.NotNull(elementType); Assert.IsType<CollectionModelBinder<int>>(result); }