示例#1
0
        public void JsonNetSchemaTestValidCase()
        {
            var validator = new JsonNetSchemaValidation.Validator
            {
                Schema = Encoding.UTF8.GetString(test_data.schema_sample1)
            };

            string message = string.Empty;

            Assert.True(validator.IsValid(Encoding.UTF8.GetString(test_data.data_sample1), out message));
            Assert.Equal("Validation Succeeded.", message);
        }
示例#2
0
        public void JsonNetSchemaTestInvalidCase()
        {
            var validator = new JsonNetSchemaValidation.Validator
            {
                Schema = Encoding.UTF8.GetString(test_data.schema_sample1)
            };

            string message = string.Empty;

            Assert.True(!validator.IsValid(Encoding.UTF8.GetString(test_data.invalid_data_sample1), out message));
            var expectedError = "Validation Errors: Integer -1 is less than minimum value of 0. Line 4, position 12.| ";

            Assert.Equal(expectedError, message);
        }