public void ShouldReturnTrueForCorrectEmail() { string[] testValues = new string[] { "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" }; foreach (string item in testValues) { Assert.IsTrue(ValidateRegex.IsEmail(item)); } }
public void ShouldReturnFalseForIncorrectEmail() { string[] testValues = new string[] { "jan.kowalski", "jan@kowalski", "jan@kowalski@com" }; foreach (string item in testValues) { Assert.IsFalse(ValidateRegex.IsEmail(item)); } }
public void ShouldReturnFalseForValueType() { decimal testValue = 12345; Assert.IsFalse(ValidateRegex.IsEmail(testValue)); }
public void ShouldReturnFalseForEmptyObject() { object testValue = new object(); Assert.IsFalse(ValidateRegex.IsEmail(testValue)); }
/// <summary> /// The method validates whether a supplied object is valid against an email pattern. /// </summary> /// <param name="objectToValidate">An object to be valdiated against regex pattern of an email address.</param> /// <returns>True - if object is valid, false - if object is invalid.</returns> public override bool Validate(object objectToValidate) { return(ValidateRegex.IsEmail(objectToValidate, pattern)); }