示例#1
0
        public void Draft07_ValidateReturnsValidOnLessThanExclusiveMaximum()
        {
            var schema = new JsonSchema07 {
                Type = JsonSchemaType.Integer, ExclusiveMaximum = 5
            };
            var json = (JsonValue)3;

            var results = schema.Validate(json);

            results.AssertValid();
        }
示例#2
0
        public void Draft07_ValidateReturnsErrorOnEqualsExclusiveMaximum()
        {
            var schema = new JsonSchema07 {
                Type = JsonSchemaType.Integer, ExclusiveMaximum = 5
            };
            var json = (JsonValue)5;

            var results = schema.Validate(json);

            results.AssertInvalid();
        }
示例#3
0
        public void Draft07_ValidateReturnsValidOnMoreThanExclusiveMinimum()
        {
            var schema = new JsonSchema07 {
                Type = JsonSchemaType.Number, ExclusiveMinimum = 5
            };
            var json = (JsonValue)10;

            var results = schema.Validate(json);

            results.AssertValid();
        }
示例#4
0
        public void ValidationPasses()
        {
            var schema = new JsonSchema07
            {
                Const = 5
            };

            JsonValue json = 5;

            var results = schema.Validate(json);

            Assert.IsTrue(results.Valid);
        }
示例#5
0
        public void ValidationFails()
        {
            var schema = new JsonSchema07
            {
                Const = 5
            };

            JsonValue json = 6;

            var results = schema.Validate(json);

            Assert.IsFalse(results.Valid);
            Assert.AreEqual("Expected: 5; Actual: 6", results.Errors.First().Message);
        }
 public static IEnumerable <IJsonSchemaPropertyValidator <JsonSchema07> > Get(JsonSchema07 schema, JsonValue json)
 {
     return(_schema07Validators.Where(v => v.Applies(schema, json)));
 }