예제 #1
0
        public void BinderTypeProperty() {
            // Arrange
            Type binderType = typeof(GoodConverter);
            ModelBinderAttribute attr = new ModelBinderAttribute(binderType);

            // Act & Assert
            Assert.AreSame(binderType, attr.BinderType);
        }
예제 #2
0
        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.");
        }
예제 #4
0
        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.");
        }