コード例 #1
0
        public void ShouldContainNoErrors()
        {
            // Arrange
            var command = new CreateDamageCodeCommand("Code", "Name", "true", "Source");

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

            // Assert
            exists.Should().BeFalse();
        }
コード例 #2
0
        public void ShouldHaveDamageCodeSourceMandatoryValidationFailureWhenSourceIsNull()
        {
            // Arrange
            string source = null;

            var command = new CreateDamageCodeCommand("Code", "Name", "true", source);

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

            // Assert
            exists.Should().BeTrue();
        }
コード例 #3
0
        public void ShouldHaveDamageCodeDamagedQuantityNotBooleanMandatoryValidationFailureWhenDamagedQuantityRequiredIsNotBoolean()
        {
            // Arrange
            string damagedQuantityRequired = "notBoolean";

            var command = new CreateDamageCodeCommand("Code", "Name", damagedQuantityRequired, "Source");

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

            // Assert
            exists.Should().BeTrue();
        }
コード例 #4
0
        public CreateDamageCodeCommand Map(CreateDamageCodeRequest request)
        {
            var result = new CreateDamageCodeCommand(request.BodyCode, request.BodyName, request.BodyDamagedQuantityRequired, request.BodySource);

            return(result);
        }