public void ShouldHaveInputNotFoundCustomFailureWhenIdIsGuidEmpty() { // Arrange var id = Guid.Empty; string name = "name"; string description = "description"; Guid icon = Guid.NewGuid(); IEnumerable <string> tags = new List <string>() { "tag1", "tag2" }; string instruction = "instruction"; List <ImageDto> images = new List <ImageDto>(); List <VideoDto> videos = new List <VideoDto>(); var version = 0; var command = new UpdateInputCommand(id, name, description, icon, tags, instruction, images, videos, version); // Act var validationResult = _validator.Validate(command); var exists = validationResult.Errors.Any( a => a.PropertyName.Equals("Id") && a.ErrorMessage.Contains(CustomFailures.InputNotFound)); // Assert exists.Should().BeTrue(); }
public void ShouldHaveInputTagMandatoryValidationFailureWhenTagsContainsWhitespaceValue() { // Arrange var id = Guid.NewGuid(); string name = "name"; string description = "description"; Guid icon = Guid.NewGuid(); IEnumerable <string> tags = new List <string>() { "tag1", " ", "tag2" }; string instruction = "instruction"; List <ImageDto> images = new List <ImageDto>(); List <VideoDto> videos = new List <VideoDto>(); var version = 0; var command = new UpdateInputCommand(id, name, description, icon, tags, instruction, images, videos, version); // Act var validationResult = _validator.Validate(command); var exists = validationResult.Errors.Any( a => a.PropertyName.Contains("Tags[1]") && a.ErrorMessage.Contains(ValidationFailures.InputTagMandatory)); // Assert exists.Should().BeTrue(); }
public void ShouldHaveInputNameCannotStartOrEndWithWhiteSpaceValidationErrorWhenNameStartsOrEndsWithWhiteSpace(string symbols) { // Arrange var id = Guid.NewGuid(); string name = symbols; string description = "description"; Guid icon = Guid.NewGuid(); IEnumerable <string> tags = new List <string>() { "tag1", " ", "tag2" }; string instruction = "instruction"; List <ImageDto> images = new List <ImageDto>(); List <VideoDto> videos = new List <VideoDto>(); var version = 0; var command = new UpdateInputCommand(id, name, description, icon, tags, instruction, images, videos, version); // Act var validationResult = _validator.Validate(command); var exists = validationResult.Errors.Any(a => a.PropertyName.Equals("Name") && a.ErrorMessage.Contains(ValidationFailures.InputNameCannotStartOrEndWithWhiteSpace)); // Assert exists.Should().BeTrue(); }
public void ShouldContainNoErrors() { // Arrange var id = Guid.NewGuid(); string name = "name"; string description = "description"; Guid icon = Guid.NewGuid(); IEnumerable <string> tags = new List <string>() { "tag1", "tag2" }; string instruction = "instruction"; List <ImageDto> images = new List <ImageDto>(); List <VideoDto> videos = new List <VideoDto>(); var version = 0; var command = new UpdateInputCommand(id, name, description, icon, tags, instruction, images, videos, version); // Act var validationResult = _validator.Validate(command); var exists = validationResult.Errors.Count > 0; // Assert exists.Should().BeFalse(); }