public void IsValid_ValidEmail_True() { var model = new EmailModelDummy { MyProperty1 = "*****@*****.**", MyProperty2 = "*****@*****.**" }; var(isValid, validationResults) = ModelValidator.Validate(model); Assert.True(isValid); Assert.Empty(validationResults); }
public void IsValid_InvalidEmail_False(string invalidEmail) { var model = new EmailModelDummy { MyProperty1 = invalidEmail, MyProperty2 = invalidEmail }; var(isValid, validationResults) = ModelValidator.Validate(model); Assert.False(isValid); Assert.Equal("Invalid e-mail address: MyProperty1.", validationResults[0].ErrorMessage); Assert.Equal("The e-mail should be valid.", validationResults[1].ErrorMessage); }