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); }
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); }
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"); }
public void ShouldNotHaveErrorWhenTitleIsNotEmpty() { _validator.ShouldNotHaveValidationErrorFor(m => m.Title, "Mr"); }