コード例 #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();
        }