Exemplo n.º 1
0
        public void Create_ForFormCollectionToken_ReturnsBinder()
        {
            // Arrange
            var provider = new FormCollectionModelBinderProvider();
            var context  = new TestModelBinderProviderContext(typeof(IFormCollection));

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

            // Assert
            Assert.IsType <FormCollectionModelBinder>(result);
        }
Exemplo n.º 2
0
        public void Create_ForNonFormCollectionTypes_ReturnsNull(Type modelType)
        {
            // Arrange
            var provider = new FormCollectionModelBinderProvider();
            var context  = new TestModelBinderProviderContext(modelType);

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

            // Assert
            Assert.Null(result);
        }
        public void Create_ForNonFormCollectionTypes_ReturnsNull(Type modelType)
        {
            // Arrange
            var provider = new FormCollectionModelBinderProvider();
            var context = new TestModelBinderProviderContext(modelType);

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

            // Assert
            Assert.Null(result);
        }
        public void Create_ForFormCollectionToken_ReturnsBinder()
        {
            // Arrange
            var provider = new FormCollectionModelBinderProvider();
            var context = new TestModelBinderProviderContext(typeof(IFormCollection));

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

            // Assert
            Assert.IsType<FormCollectionModelBinder>(result);
        }
Exemplo n.º 5
0
        public void Create_ThrowsException_ForFormCollectionModelType(Type modelType)
        {
            // Arrange
            var provider = new FormCollectionModelBinderProvider();
            var context  = new TestModelBinderProviderContext(modelType);

            // Act & Assert
            var exception = Assert.Throws <InvalidOperationException>(() => provider.GetBinder(context));

            Assert.Equal(
                $"The '{typeof(FormCollectionModelBinder).FullName}' cannot bind to a model of type '{modelType.FullName}'. Change the model type to '{typeof(IFormCollection).FullName}' instead.",
                exception.Message);
        }