public void Should_PassValidation_When_AllRulesPass() { // Arrange var userProfileDtoValidator = new UserProfileDtoValidator(); var userProfileDto = new UserProfileDto() { DisplayName = "displayname" }; // Act var result = userProfileDtoValidator.Validate(userProfileDto, ruleSet: "CreateUser"); var isValid = result.IsValid; // Assert isValid.Should().Be(true); }
public void Should_FailValidationWithMessage_When_DisplayNameIsEmpty() { // Arrange var userProfileDtoValidator = new UserProfileDtoValidator(); var userProfileDto = new UserProfileDto() { DisplayName = "" }; // Act var result = userProfileDtoValidator.Validate(userProfileDto, ruleSet: "CreateUser"); var isValid = result.IsValid; var errors = result.Errors; // Assert isValid.Should().Be(false); errors.Count.Should().Be(1); errors[0].ToString().Should().Be("Display name is required."); }