public void ShouldReturnFalseForIncorrectMobilePhone() { string[] testValues = new string[] { "+48696588", "+4869658813", "+486965881", "+48 696 588", "+48 696 588 13", "+48 696 588 1", "some text", string.Empty }; foreach (string item in testValues) { Assert.IsFalse(ValidateRegex.IsMobilePhone(item)); } }
public void ShouldReturnTrueForCorrectMobilePhone() { string[] testValues = new string[] { "+48696588133", "48696588133", "48 696 588 133", "+48 696 588 133", "+48 696 588 133" }; foreach (string item in testValues) { Assert.IsTrue(ValidateRegex.IsMobilePhone(item)); } }
/// <summary> /// The method validates whether a supplied object is valid against a mobile phone pattern. /// </summary> /// <param name="objectToValidate">An object to be valdiated against regex pattern of a mobile phone number.</param> /// <returns>True - if object is valid, false - if object is invalid.</returns> public override bool Validate(object objectToValidate) { return(ValidateRegex.IsMobilePhone(objectToValidate, pattern)); }
public void MobilePhone_ShouldReturnFalseForValueType() { decimal testValue = 12345; Assert.IsFalse(ValidateRegex.IsMobilePhone(testValue)); }
public void MobilePhone_ShouldReturnFalseForEmptyObject() { object testValue = new object(); Assert.IsFalse(ValidateRegex.IsMobilePhone(testValue)); }