示例#1
0
        public void ShouldHaveInputNameMandatoryValidationFailureWhenNameIsEmpty()
        {
            // Arrange
            var    name               = string.Empty;
            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 command = new CreateInputCommand(name, description, icon, tags, instruction, images, videos);

            // Act
            var validationResult = _validator.Validate(command);
            var exists           =
                validationResult.Errors.Any(
                    a => a.PropertyName.Equals("Name") && a.ErrorMessage.Contains(ValidationFailures.InputNameMandatory));

            // Assert
            exists.Should().BeTrue();
        }
示例#2
0
        public void ShouldContainNoErrorsWhenNoTags()
        {
            // Arrange
            string name                 = "name";
            string description          = "description";
            Guid   icon                 = Guid.NewGuid();
            IEnumerable <string> tags   = new List <string>();
            string          instruction = "instruction";
            List <ImageDto> images      = new List <ImageDto>();
            List <VideoDto> videos      = new List <VideoDto>();

            var command = new CreateInputCommand(name, description, icon, tags, instruction, images, videos);

            // Act
            var validationResult = _validator.Validate(command);
            var exists           = validationResult.Errors.Count > 0;

            // Assert
            exists.Should().BeFalse();
        }
示例#3
0
        public void ShouldHaveInputNameCannotStartOrEndWithWhiteSpaceValidationErrorWhenNameStartsOrEndsWithWhiteSpace(string symbols)
        {
            // Arrange
            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 command = new CreateInputCommand(name, description, icon, tags, instruction, images, videos);

            // 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();
        }