예제 #1
0
        public void given_valid_object_then_Validate_succeeds()
        {
            var    instance = new RootObject();
            Action action   = () => MessageValidator.Validate(instance);

            action.Should().NotThrow();
        }
예제 #2
0
        public void given_null_stem_then_Validate_succeeds()
        {
            var instance = new RootObject {
                StemObjectProperty = null
            };
            Action action = () => MessageValidator.Validate(instance);

            action.Should().NotThrow();
        }
예제 #3
0
        public void given_root_has_invalid_property_then_Validate_throws_ValidationException()
        {
            var instance = new RootObject
            {
                Int32Property = -1,
            };

            Action action = () => MessageValidator.Validate(instance);

            action.Should().Throw <ValidationException>()
            .Where(x => x.ValidationAttribute is RangeAttribute)
            .Which.ValidationResult.MemberNames.Should()
            .BeEquivalentTo("Int32Property");
        }
예제 #4
0
        public void given_stem_has_invalid_property_then_Validate_throws_ValidationException()
        {
            var instance = new RootObject
            {
                StemObjectProperty =
                {
                    StringProperty = "f to the o to the o",
                },
            };

            Action action = () => MessageValidator.Validate(instance);

            action.Should().Throw <ValidationException>()
            .Where(x => x.ValidationAttribute is StringLengthAttribute)
            .Which.ValidationResult.MemberNames.Should()
            .BeEquivalentTo("StemObjectProperty.StringProperty");
        }
예제 #5
0
        public void given_null_argument_then_Validate_succeeds()
        {
            Action action = () => MessageValidator.Validate(instance: null);

            action.Should().NotThrow();
        }