示例#1
0
 public void WhenValidatingUserWithCountryAsUSAndFiveDigitNumericPostalCode_ThenValidationSucceeds()
 {
     var user = new FirebrickUserViewModel
         {
             DisplayName = "name",
             Country = "United States",
             PostalCode = "12345",
             Password = "******",
             UserName = "******"
         };
     ValidateUser(user);
 }
示例#2
0
 public void WhenValidatingUserWithCountryAsUSAndLongNumericPostalCode_ThenValidationFails()
 {
     var user = new FirebrickUserViewModel
         {
             DisplayName = "name",
             Country = "United States",
             PostalCode = "123456",
             Password = "******",
             UserName = "******"
         };
     var exception = Assert.Throws<ValidationException>(() => ValidateUser(user));
     Assert.Contains("PostalCode", exception.ValidationResult.MemberNames);
 }
示例#3
0
 public void WhenValidatingUserWithLongCountry_ThenValidationFails()
 {
     var user = new FirebrickUserViewModel
         {
             DisplayName = "name",
             Country = "ThisIsAVeryVeryVeryVeryVeryLongStringThatShouldNotBeAllowed",
             PostalCode = "12345",
             Password = "******",
             UserName = "******"
         };
     var exception = Assert.Throws<ValidationException>(() => ValidateUser(user));
     Assert.Contains("Country", exception.ValidationResult.MemberNames);
 }
示例#4
0
 /// <summary>
 /// The validate user.
 /// </summary>
 /// <param name="user">
 /// The user.
 /// </param>
 private static void ValidateUser(FirebrickUserViewModel user)
 {
     var context = new ValidationContext(user, null, null);
     Validator.ValidateObject(user, context, true);
 }