예제 #1
0
        public void ShouldContainNoErrors(string description, string image)
        {
            // Arrange
            var name    = "name";
            var command = new CreateLayoutCommand(name, description, image);

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

            // Assert
            exists.Should().BeFalse();
        }
예제 #2
0
        public void ShouldHaveLayoutNameCannotStartOrEndWithWhiteSpaceValidationErrorWhenNameStartsOrEndsWithWhiteSpace(string symbols)
        {
            // Arrange
            var name        = symbols;
            var description = "description";
            var image       = "image";
            var command     = new CreateLayoutCommand(name, description, image);

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

            // Assert
            exists.Should().BeTrue();
        }
예제 #3
0
        public void ShouldHaveLayoutNameMandatoryValidationFailureWhenNameIsNull()
        {
            // Arrange
            string name        = null;
            var    description = "description";
            var    image       = "image";
            var    command     = new CreateLayoutCommand(name, description, image);

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

            // Assert
            exists.Should().BeTrue();
        }
예제 #4
0
        public CreateLayoutCommand Map(CreateLayoutRequest request)
        {
            var result = new CreateLayoutCommand(request.BodyName, request.BodyDescription, request.BodyImage);

            return(result);
        }