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); }
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); }