public void PersonFirstnameValidationTest() { Person person = new Person(); person.Validate(); Assert.AreEqual("", person.Firstname); Assert.AreEqual(Resources.FirstnameMandatory, person.GetErrors("Firstname").Single().ErrorMessage); person.Firstname = new string('A', 31); Assert.AreEqual(string.Format(CultureInfo.CurrentCulture, Resources.FirstnameMaxLength, "Firstname", 30), person.GetErrors("Firstname").Single().ErrorMessage); person.Firstname = new string('A', 30); Assert.IsFalse(person.GetErrors("Firstname").Any()); }
public void PersonEmailValidationTest() { Person person = new Person(); person.Validate(); Assert.IsNull(person.Email); Assert.IsFalse(person.GetErrors("Email").Any()); person.Email = ""; Assert.IsNull(person.Email); Assert.IsFalse(person.GetErrors("Email").Any()); person.Email = new string('A', 92) + "@mail.com"; Assert.AreEqual(string.Format(CultureInfo.CurrentCulture, Resources.EmailMaxLength, "Email", 100), person.GetErrors("Email").Single().ErrorMessage); person.Email = "my." + new string('A', 88) + "@mail.com"; Assert.IsFalse(person.GetErrors("Email").Any()); person.Email = "harry.potter"; Assert.AreEqual(Resources.EmailInvalid, person.GetErrors("Email").Single().ErrorMessage); person.Email = "harry.potter@hogwarts"; Assert.AreEqual(Resources.EmailInvalid, person.GetErrors("Email").Single().ErrorMessage); person.Email = "*****@*****.**"; Assert.IsFalse(person.GetErrors("Email").Any()); }