Esempio n. 1
0
        public void ReplaceEmptyStringWithNull_ConvertEmptyStringToNullDisabled_ModelIsNotEmptyString_LeavesModelAlone()
        {
            // Arrange
            ModelMetadata modelMetadata = GetMetadata(typeof(string));

            modelMetadata.ConvertEmptyStringToNull = true;

            // Act
            object model = 42;

            ModelBindingHelper.ReplaceEmptyStringWithNull(modelMetadata, ref model);

            // Assert
            Assert.Equal(42, model);
        }
Esempio n. 2
0
        public void ReplaceEmptyStringWithNull_ConvertEmptyStringToNullEnabled_ModelIsWhitespaceString_ReplacesModelWithNull()
        {
            // Arrange
            ModelMetadata modelMetadata = GetMetadata(typeof(string));

            modelMetadata.ConvertEmptyStringToNull = true;

            // Act
            object model = "     "; // whitespace

            ModelBindingHelper.ReplaceEmptyStringWithNull(modelMetadata, ref model);

            // Assert
            Assert.Null(model);
        }