Ejemplo n.º 1
0
        public async Task ValueIsRequired(string value)
        {
            var validator = new itemItemValidator();
            var target    = new ItemAsset {
                Name = "SomeName", Location = value
            };

            var result = await validator.ValidateAsync(target);

            result.Should().NotBeNull("because a validation result should have been returned");
            result.Should().ContainSingle(error => ((error.MemberPath == nameof(ItemAsset.Location)) && (error.Code == ErrorCode.ValueIsRequired.ToString())), "because the value was not provided");
        }
Ejemplo n.º 2
0
        public async Task ValueIsValidated()
        {
            var value     = new String('j', itemItemValidator.MaxValueLength + 1);
            var validator = new itemItemValidator();
            var target    = new ItemAsset {
                Name = "SomeName", Location = value
            };

            var result = await validator.ValidateAsync(target);

            result.Should().NotBeNull("because a validation result should have been returned");
            result.Should().ContainSingle(error => ((error.MemberPath == nameof(ItemAsset.Location)) && (error.Code == ErrorCode.LengthIsInvalid.ToString())), "because the value was too long");
        }