public void Should_Throw_Validation_Exception_For_Empty_Name() { // Arrange var command = new CreateDummyModelCommand(); // Act var validator = new CreateDummyModelCommandValidator(); var validationResult = validator.Validate(command); // Assert validationResult.IsValid.Should().Be(false); validationResult.Errors[0].ErrorMessage.Should().Be("'Name' must not be empty."); validationResult.Errors[0].ErrorCode.Should().Be("NotEmptyValidator"); validationResult.Errors[0].PropertyName.Should().Be("Name"); validationResult.Errors[0].Severity.Should().Be(Severity.Error); }
public void Should_Throw_Validation_Exception_For_Larger_Name() { // Arrange string invalidName = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do" + "eiusmod tempor incididunt ut labore et dolore magna aliqua."; var command = new CreateDummyModelCommand() { Name = invalidName, }; // Act var validator = new CreateDummyModelCommandValidator(); var validationResult = validator.Validate(command); // Assert validationResult.IsValid.Should().Be(false); validationResult.Errors[0].ErrorMessage.Should().Be($"The length of 'Name' must be" + $" {DummyModelValidationRules.NameMaximumLength} characters or fewer." + $" You entered {invalidName.Length} characters."); validationResult.Errors[0].ErrorCode.Should().Be("MaximumLengthValidator"); validationResult.Errors[0].PropertyName.Should().Be("Name"); validationResult.Errors[0].Severity.Should().Be(Severity.Error); }