コード例 #1
0
        public void CreateRuleSet_Should_not_have_error_when()
        {
            var contact = new ContactModel {
                Id = 0, Name = "Jeremy"
            };

            _validator.ShouldNotHaveValidationErrorFor(x => x.Id, contact, ContactValidator.CreateRuleSet);
            _validator.ShouldNotHaveValidationErrorFor(x => x.Name, contact, ContactValidator.CreateRuleSet);
        }
コード例 #2
0
        public void PostContactFreelance_WithOutVATNumber()
        {
            var person = new ContactDTO {
                Id = 1, FirstName = "Laurent", LastName = "FIEVET", GSMNumber = "111515151", IsFreelance = true, VATNumber = "2145245545", Address = new AddressDTO {
                    Name = "test", City = "gfdfd", Country = "fdfdfd", PostalCode = "dfdfd", Street = "fdfdfd", StreetNumber = "fdfdfdfd"
                }
            };

            validator.ShouldNotHaveValidationErrorFor(x => x.VATNumber, person);
        }
コード例 #3
0
        public void Contact_Validation()
        {
            var validator = new ContactValidator();

            validator.ShouldHaveValidationErrorFor(x => x.Name, new ContactViewModel());
            validator.ShouldHaveValidationErrorFor(x => x.Email, new ContactViewModel());
            validator.ShouldHaveValidationErrorFor(x => x.Type, new ContactViewModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, "")
            .WithErrorMessage("Name can not be empty.");
            validator.ShouldHaveValidationErrorFor(x => x.Email, "")
            .WithErrorMessage("Email can not be empty.");
            validator.ShouldHaveValidationErrorFor(x => x.Email, "abc123")
            .WithErrorMessage("Invalid email address.");
            validator.ShouldHaveValidationErrorFor(x => x.Type, "")
            .WithErrorMessage("Select type.");

            validator.ShouldNotHaveValidationErrorFor(x => x.Name, "name");
            validator.ShouldNotHaveValidationErrorFor(x => x.Email, "*****@*****.**");
            validator.ShouldNotHaveValidationErrorFor(x => x.Type, "client");
        }
コード例 #4
0
 public void ShouldNotHaveErrorWhenTitleIsNotEmpty()
 {
     _validator.ShouldNotHaveValidationErrorFor(m => m.Title, "Mr");
 }