Esempio n. 1
0
        public void ShouldContainNoErrors()
        {
            // Arrange
            var id               = Guid.NewGuid();
            var name             = Guid.NewGuid().ToString();
            var nameOnAplication = "any";
            var description      = "any";
            var icon             = Guid.NewGuid();
            var tags             = new List <string>();
            var defaultRemarks   = new List <string>();

            var command = new UpdateRemarkCommand(id, name, nameOnAplication, description, icon, tags, defaultRemarks, version: 0);

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

            // Assert
            exists.Should().BeFalse();
        }
Esempio n. 2
0
        public void ShouldHaveRemarkNameCannotStartOrEndWithWhiteSpaceValidationErrorWhenNameStartsOrEndsWithWhiteSpace(string symbols)
        {
            // Arrange
            var id               = Guid.NewGuid();
            var name             = symbols;
            var nameOnAplication = "any";
            var description      = "any";
            var icon             = Guid.NewGuid();
            var tags             = new List <string>();
            var defaultRemarks   = new List <string>();

            var command = new UpdateRemarkCommand(id, name, nameOnAplication, description, icon, tags, defaultRemarks, version: 0);

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

            // Assert
            exists.Should().BeTrue();
        }
Esempio n. 3
0
        public void ShouldHaveNameMandatoryValidationErrorWhenNameIsEmpty()
        {
            // Arrange
            var id               = Guid.NewGuid();
            var name             = string.Empty;
            var nameOnAplication = "any";
            var description      = "any";
            var icon             = Guid.NewGuid();
            var tags             = new List <string>();
            var defaultRemarks   = new List <string>();

            var command = new UpdateRemarkCommand(id, name, nameOnAplication, description, icon, tags, defaultRemarks, version: 0);

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

            // Assert
            exists.Should().BeTrue();
        }
Esempio n. 4
0
        public void ShouldHaveRemarkNotFoundCustomFailureWhenIdIsGuidEmpty()
        {
            // Arrange
            var id               = Guid.NewGuid();
            var name             = Guid.NewGuid().ToString();
            var nameOnAplication = "any";
            var description      = "any";
            var icon             = Guid.NewGuid();
            var tags             = new List <string>();
            var defaultRemarks   = new List <string>();

            var command = new UpdateRemarkCommand(Guid.Empty, name, nameOnAplication, description, icon, tags, defaultRemarks, version: 0);

            // Act
            var validationResult = _validator.Validate(command);
            var exists           =
                validationResult.Errors.Any(
                    a => a.PropertyName.Equals("Id") && a.ErrorMessage.Contains(CustomFailures.RemarkNotFound));

            // Assert
            exists.Should().BeTrue();
        }