public void UnevaluatedProperties_SchemaEvaluatedOnInvalidProperty_ErrorDisplayed()
        {
            string schemaJson = @"{
                ""type"": ""object"",
                ""properties"": {
                    ""foo"": { ""type"": ""string"" }
                },
                ""unevaluatedProperties"": {
                    ""type"": ""string"",
                    ""maxLength"": 2
                }
            }";

            string json = @"{
                    ""foo"": ""foo"",
                    ""bar"": ""bar""
                }";

            SchemaValidationEventArgs validationEventArgs = null;

            JSchemaValidatingReader reader = new JSchemaValidatingReader(new JsonTextReader(new StringReader(json)));

            reader.ValidationEventHandler += (sender, args) => { validationEventArgs = args; };
            reader.Schema = JSchema.Parse(schemaJson);

            while (reader.Read())
            {
            }

            Assert.IsNotNull(validationEventArgs);
            Assert.AreEqual("Property 'bar' has not been successfully evaluated and the schema does not allow unevaluated properties.", validationEventArgs.ValidationError.Message);
            Assert.AreEqual(ErrorType.UnevaluatedProperties, validationEventArgs.ValidationError.ErrorType);
            Assert.AreEqual("String 'bar' exceeds maximum length of 2.", validationEventArgs.ValidationError.ChildErrors[0].Message);
        }
        public void UnevaluatedItems_SchemaEvaluatedOnInvalidItem_ErrorDisplayed()
        {
            string schemaJson = @"{
                ""type"": ""array"",
                ""unevaluatedItems"": {
                    ""type"": ""string"",
                    ""minLength"": 3
                }
            }";

            string json = @"[ ""foo"", ""fo"" ]";

            SchemaValidationEventArgs validationEventArgs = null;

            JSchemaValidatingReader reader = new JSchemaValidatingReader(new JsonTextReader(new StringReader(json)));

            reader.ValidationEventHandler += (sender, args) => { validationEventArgs = args; };
            reader.Schema = JSchema.Parse(schemaJson);

            while (reader.Read())
            {
            }

            Assert.IsNotNull(validationEventArgs);
            Assert.AreEqual("Item at index 1 has not been successfully evaluated and the schema does not allow unevaluated items.", validationEventArgs.ValidationError.Message);
            Assert.AreEqual(ErrorType.UnevaluatedItems, validationEventArgs.ValidationError.ErrorType);
            Assert.AreEqual("String 'fo' is less than minimum length of 3.", validationEventArgs.ValidationError.ChildErrors[0].Message);
        }
        public void UnevaluatedItems_Schema_NoMatch()
        {
            string schemaJson = @"{
                ""type"": ""array"",
                ""unevaluatedItems"": {
                    ""type"": ""string"",
                    ""minLength"": 3
                }
            }";

            string json = @"[ ""fo"" ]";

            SchemaValidationEventArgs validationEventArgs = null;

            JSchemaValidatingReader reader = new JSchemaValidatingReader(new JsonTextReader(new StringReader(json)));

            reader.ValidationEventHandler += (sender, args) => { validationEventArgs = args; };
            reader.Schema = JSchema.Parse(schemaJson);

            while (reader.Read())
            {
            }

            Assert.IsNotNull(validationEventArgs);
            Assert.AreEqual("Item at index 0 has not been successfully evaluated and the schema does not allow unevaluated items. Path '', line 1, position 8.", validationEventArgs.Message);
            Assert.AreEqual(ErrorType.UnevaluatedItems, validationEventArgs.ValidationError.ErrorType);
        }
        public void UnevaluatedProperties_NotAllowed_NoMatch()
        {
            string schemaJson = @"{
                ""type"": ""object"",
                ""properties"": {
                    ""foo"": { ""type"": ""string"" }
                },
                ""unevaluatedProperties"": false
            }";

            string json = "{'bar':true}";

            SchemaValidationEventArgs validationEventArgs = null;

            JSchemaValidatingReader reader = new JSchemaValidatingReader(new JsonTextReader(new StringReader(json)));

            reader.ValidationEventHandler += (sender, args) => { validationEventArgs = args; };
            reader.Schema = JSchema.Parse(schemaJson);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.StartObject, reader.TokenType);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.Boolean, reader.TokenType);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.EndObject, reader.TokenType);

            Assert.IsNotNull(validationEventArgs);
            Assert.AreEqual("Property 'bar' has not been successfully evaluated and the schema does not allow unevaluated properties. Path '', line 1, position 12.", validationEventArgs.Message);
            Assert.AreEqual(ErrorType.UnevaluatedProperties, validationEventArgs.ValidationError.ErrorType);
        }
        public void UnevaluatedItems_ConditionalSchema_NoMatch()
        {
            string schemaJson = @"{
                ""type"": ""array"",
                ""items"": [
                    { ""type"": ""string"" }
                ],
                ""allOf"": [
                    {
                        ""items"": [
                            true,
                            { ""allOf"": [ false ] }
                        ]
                    }
                ],
                ""unevaluatedItems"": false
            }";

            string json = @"[""foo"", 42]";

            SchemaValidationEventArgs validationEventArgs = null;

            JSchemaValidatingReader reader = new JSchemaValidatingReader(new JsonTextReader(new StringReader(json)));

            reader.ValidationEventHandler += (sender, args) => { validationEventArgs = args; };
            reader.Schema = JSchema.Parse(schemaJson);

            while (reader.Read())
            {
            }

            Assert.IsNotNull(validationEventArgs);
            Assert.AreEqual("Item at index 1 has not been successfully evaluated and the schema does not allow unevaluated items. Path '', line 1, position 11.", validationEventArgs.Message);
        }
Esempio n. 6
0
        public void WriteBigInteger()
        {
            JSchema schema = new JSchema();

            schema.Type = JSchemaType.Array;
            schema.Items.Add(new JSchema
            {
                Type    = JSchemaType.Integer,
                Maximum = 5000
            });

            SchemaValidationEventArgs a = null;

            StringWriter            sw               = new StringWriter();
            JsonTextWriter          writer           = new JsonTextWriter(sw);
            JSchemaValidatingWriter validatingWriter = new JSchemaValidatingWriter(writer);

            validatingWriter.Schema = schema;
            validatingWriter.ValidationEventHandler += (sender, args) => { a = args; };

            validatingWriter.WriteStartArray();

            validatingWriter.WriteValue(BigInteger.Parse("4001"));
            Assert.IsNull(a);

            validatingWriter.WriteValue((object)BigInteger.Parse("4002"));
            Assert.IsNull(a);

            validatingWriter.WriteValue(45);
            Assert.IsNull(a);

            validatingWriter.WriteValue(BigInteger.Parse("4000000000000000000000000000000000000000001"));
            Assert.IsNotNull(a);
            StringAssert.AreEqual(@"Integer 4000000000000000000000000000000000000000001 exceeds maximum value of 5000. Path '[3]'.", a.Message);
            Assert.AreEqual(BigInteger.Parse("4000000000000000000000000000000000000000001"), a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue(46);
            Assert.IsNull(a);

            validatingWriter.WriteValue((object)BigInteger.Parse("4000000000000000000000000000000000000000002"));
            Assert.IsNotNull(a);
            StringAssert.AreEqual(@"Integer 4000000000000000000000000000000000000000002 exceeds maximum value of 5000. Path '[5]'.", a.Message);
            Assert.AreEqual(BigInteger.Parse("4000000000000000000000000000000000000000002"), a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue(47);
            Assert.IsNull(a);

            validatingWriter.WriteEndArray();
            Assert.IsNull(a);

            Assert.AreEqual(@"[4001,4002,45,4000000000000000000000000000000000000000001,46,4000000000000000000000000000000000000000002,47]", sw.ToString());
        }
        public void UnevaluatedProperties_AnyOf_NoMatch()
        {
            string schemaJson = @"{
                ""type"": ""object"",
                ""properties"": {
                    ""foo"": { ""type"": ""string"" }
                },
                ""anyOf"": [
                    {
                        ""properties"": {
                            ""bar"": { ""const"": ""bar"" }
                        },
                        ""required"": [""bar""]
                    },
                    {
                        ""properties"": {
                            ""baz"": { ""const"": ""baz"" }
                        },
                        ""required"": [""baz""]
                    },
                    {
                        ""properties"": {
                            ""quux"": { ""const"": ""quux"" }
                        },
                        ""required"": [""quux""]
                    }
                ],
                ""unevaluatedProperties"": false
            }";

            string json = @"{
                    ""foo"": ""foo"",
                    ""bar"": ""bar"",
                    ""baz"": ""not-baz""
                }";

            SchemaValidationEventArgs validationEventArgs = null;

            JSchemaValidatingReader reader = new JSchemaValidatingReader(new JsonTextReader(new StringReader(json)));

            reader.ValidationEventHandler += (sender, args) => { validationEventArgs = args; };
            reader.Schema = JSchema.Parse(schemaJson);

            while (reader.Read())
            {
            }

            Assert.IsNotNull(validationEventArgs);
            Assert.AreEqual("Property 'baz' has not been successfully evaluated and the schema does not allow unevaluated properties. Path '', line 5, position 17.", validationEventArgs.Message);
            Assert.AreEqual(ErrorType.UnevaluatedProperties, validationEventArgs.ValidationError.ErrorType);
        }
Esempio n. 8
0
        public void ObjectBasicValidation_Fail()
        {
            JSchema schema = new JSchema();

            schema.Type = JSchemaType.Object;
            schema.Properties.Add("prop1", new JSchema
            {
                Type = JSchemaType.Integer
            });
            schema.Properties.Add("prop2", new JSchema
            {
                Type = JSchemaType.Boolean
            });

            SchemaValidationEventArgs a = null;

            StringWriter            sw               = new StringWriter();
            JsonTextWriter          writer           = new JsonTextWriter(sw);
            JSchemaValidatingWriter validatingWriter = new JSchemaValidatingWriter(writer);

            validatingWriter.Schema = schema;
            validatingWriter.ValidationEventHandler += (sender, args) => { a = args; };

            validatingWriter.WriteStartObject();

            validatingWriter.WritePropertyName("prop1");
            validatingWriter.WriteValue(true);
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got Boolean. Path 'prop1'.", a.Message);
            Assert.AreEqual(true, a.ValidationError.Value);
            a = null;

            validatingWriter.WritePropertyName("prop2");
            validatingWriter.WriteValue(45);
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Boolean but got Integer. Path 'prop2'.", a.Message);
            Assert.AreEqual(45, a.ValidationError.Value);
            a = null;

            validatingWriter.WritePropertyName("prop3");
            validatingWriter.WriteValue(45);

            validatingWriter.WriteEndObject();

            Assert.IsNull(a);

            Assert.AreEqual(@"{""prop1"":true,""prop2"":45,""prop3"":45}", sw.ToString());
        }
        public void TryGetPatternRegex_MatchTimeout_Null()
        {
            Regex  regex1        = null;
            string errorMessage1 = null;

            RegexHelpers.TryGetPatternRegex("[abc]", null, ref regex1, ref errorMessage1);

            Assert.IsNotNull(regex1);

            Regex  regex2        = regex1;
            string errorMessage2 = errorMessage1;

            RegexHelpers.TryGetPatternRegex("[abc]", null, ref regex2, ref errorMessage2);

            Assert.AreEqual(regex1, regex2);
        }
        public void TryGetPatternRegex_MatchTimeout_Defined()
        {
            TimeSpan matchTimeout = TimeSpan.FromSeconds(1);

            Regex  regex1        = null;
            string errorMessage1 = null;

            RegexHelpers.TryGetPatternRegex("[abc]", matchTimeout, ref regex1, ref errorMessage1);

            Assert.IsNotNull(regex1);

            Regex  regex2        = regex1;
            string errorMessage2 = errorMessage1;

            RegexHelpers.TryGetPatternRegex("[abc]", matchTimeout, ref regex2, ref errorMessage2);

            Assert.AreEqual(regex1, regex2);
        }
Esempio n. 11
0
        public void NestedScopes()
        {
            JSchema schema = JSchema.Parse(@"{
                ""properties"": {
                    ""foo"": {""type"": ""integer""},
                    ""bar"": {""type"": ""string""}
                }
            }");

            SchemaValidationEventArgs a = null;

            StringWriter            sw               = new StringWriter();
            JsonTextWriter          writer           = new JsonTextWriter(sw);
            JSchemaValidatingWriter validatingWriter = new JSchemaValidatingWriter(writer);

            validatingWriter.Schema = schema;
            validatingWriter.ValidationEventHandler += (sender, args) => { a = args; };

            validatingWriter.WriteStartObject();
            validatingWriter.WritePropertyName("foo");
            validatingWriter.WriteStartArray();

            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got Array. Path 'foo'.", a.Message);
            Assert.AreEqual(null, a.ValidationError.Value);
            a = null;

            validatingWriter.WriteEndArray();
            validatingWriter.WritePropertyName("bar");
            validatingWriter.WriteStartObject();

            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected String but got Object. Path 'bar'.", a.Message);
            Assert.AreEqual(null, a.ValidationError.Value);
            a = null;

            validatingWriter.WriteEndObject();
            validatingWriter.WriteEndObject();

            Assert.IsNull(a);

            Assert.AreEqual(@"{""foo"":[],""bar"":{}}", sw.ToString());
        }
Esempio n. 12
0
        public void WriteStartConstructor()
        {
            JSchema schema = new JSchema();

            schema.Type = JSchemaType.Array;
            schema.Items.Add(new JSchema
            {
                Type = JSchemaType.Integer
            });

            SchemaValidationEventArgs a = null;

            StringWriter            sw               = new StringWriter();
            JsonTextWriter          writer           = new JsonTextWriter(sw);
            JSchemaValidatingWriter validatingWriter = new JSchemaValidatingWriter(writer);

            validatingWriter.Schema = schema;
            validatingWriter.ValidationEventHandler += (sender, args) => { a = args; };

            validatingWriter.WriteStartConstructor("Test");

            Assert.IsNotNull(a);
            StringAssert.AreEqual(@"Invalid type. Expected Array but got Constructor. Path ''.", a.Message);
            Assert.AreEqual(null, a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue(1);
            Assert.IsNull(a);

            validatingWriter.WriteValue('e');
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got String. Path '[1]'.", a.Message);
            Assert.AreEqual("e", a.ValidationError.Value);
            a = null;

            validatingWriter.WriteComment("comment!");
            Assert.IsNull(a);

            validatingWriter.WriteEndConstructor();
            Assert.IsNull(a);

            Assert.AreEqual(@"new Test(1,""e""/*comment!*/)", sw.ToString());
        }
Esempio n. 13
0
        public void Test()
        {
            JSchemaPreloadedResolver resolver = new JSchemaPreloadedResolver();

            resolver.Add(new Uri("http://example.com/schema1.json"), Schema1);
            resolver.Add(new Uri("http://example.com/schema2.json"), Schema2);

            JSchema schema = JSchema.Parse(Schema1, resolver);

            JSchema fooSchema = schema.Properties["foo"];

            Assert.AreEqual(JSchemaType.String, fooSchema.Properties["value"].Type);

            // because the root schema has no BaseUri this schema won't be set back
            ExceptionAssert.Throws <JSchemaException>(() =>
            {
                JSchema bazSchema = (JSchema)schema.ExtensionData["definitions"]["baz"];
                Assert.IsNotNull(bazSchema);
            }, "Cannot convert JToken to JSchema. No schema is associated with this token.");

            Console.WriteLine(schema.ToString());
        }
Esempio n. 14
0
        public void ArrayBasicValidation_Fail()
        {
            JSchema schema = new JSchema();

            schema.Type = JSchemaType.Array;
            schema.Items.Add(new JSchema
            {
                Type = JSchemaType.Integer
            });

            SchemaValidationEventArgs a = null;

            StringWriter            sw               = new StringWriter();
            JsonTextWriter          writer           = new JsonTextWriter(sw);
            JSchemaValidatingWriter validatingWriter = new JSchemaValidatingWriter(writer);

            validatingWriter.Schema = schema;
            validatingWriter.ValidationEventHandler += (sender, args) => { a = args; };

            validatingWriter.WriteStartArray();

            validatingWriter.WriteValue("string");
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got String. Path '[0]'.", a.Message);
            Assert.AreEqual("string", a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue(true);
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got Boolean. Path '[1]'.", a.Message);
            Assert.AreEqual(true, a.ValidationError.Value);
            a = null;

            validatingWriter.WriteEndArray();
            Assert.IsNull(a);

            Assert.AreEqual(@"[""string"",true]", sw.ToString());
        }
        public void Test()
        {
            // Arrange
            string rootSchemaPath = TestHelpers.ResolveFilePath(@"resources\schemas\custom\issue0198\sample.json");

            // Act
            JSchema schema;

            using (Stream file = File.OpenRead(rootSchemaPath))
                using (JsonReader reader = new JsonTextReader(new StreamReader(file)))
                {
                    schema = JSchema.Load(reader, new JSchemaReaderSettings
                    {
                        Resolver = new JSchemaUrlResolver(),
                        BaseUri  = new Uri(rootSchemaPath, UriKind.RelativeOrAbsolute)
                    });
                }

            // Assert
            Assert.IsNotNull(schema);
            Assert.AreEqual(JSchemaType.Object, schema.Type);
            Assert.AreEqual(2, schema.AllOf.Count);
            Assert.AreEqual(JSchemaType.String, schema.AllOf[0].Properties["address"].Type);
        }
        public void SchemaReused_UnevaluatedProperties()
        {
            string schemaJson = @"{
  ""type"": ""object"",
  ""definitions"": {
    ""allRegionProperties"": {
      ""properties"": {
        ""Type"": true,
        ""Slug"": true
      }
    }
  },
  ""required"": [
    ""Type""
  ],
  ""properties"": {
    ""Type"": {
      ""enum"": [
        ""region"",
        ""geo"",
        ""non-regional""
      ]
    }
  },
  ""oneOf"": [
    {
      ""if"": {
        ""properties"": {
          ""Type"": {
            ""enum"": [
              ""geo""
            ]
          }
        }
      },
      ""then"": {
        ""$ref"": ""#/definitions/allRegionProperties"",
        ""unevaluatedProperties"": false
      },
      ""else"": false
    },
    {
      ""if"": {
        ""properties"": {
          ""Type"": {
            ""enum"": [
              ""non-regional""
            ]
          }
        }
      },
      ""then"": {
        ""allOf"": [
          {
            ""$ref"": ""#/definitions/allRegionProperties"",
            ""unevaluatedProperties"": false
          }
        ]
      },
      ""else"": false
    }
  ]
}";

            string json = @"{
  ""Type"": ""non-regional"",
  ""Unknown"": ""2 spooky""
}";

            SchemaValidationEventArgs validationEventArgs = null;

            JSchemaValidatingReader reader = new JSchemaValidatingReader(new JsonTextReader(new StringReader(json)));

            reader.ValidationEventHandler += (sender, args) => { validationEventArgs = args; };
            reader.Schema = JSchema.Parse(schemaJson);

            while (reader.Read())
            {
            }

            Assert.IsNotNull(validationEventArgs);
            Assert.AreEqual("JSON is valid against no schemas from 'oneOf'.", validationEventArgs.ValidationError.Message);
            Assert.AreEqual("JSON does not match schema from 'then'.", validationEventArgs.ValidationError.ChildErrors[0].Message);
            Assert.AreEqual("JSON does not match all schemas from 'allOf'. Invalid schema indexes: 0.", validationEventArgs.ValidationError.ChildErrors[0].ChildErrors[0].Message);
            Assert.AreEqual("Property 'Unknown' has not been successfully evaluated and the schema does not allow unevaluated properties.", validationEventArgs.ValidationError.ChildErrors[0].ChildErrors[0].ChildErrors[0].Message);
        }
Esempio n. 17
0
        public void WriteValue_Object()
        {
            JSchema schema = new JSchema();

            schema.Type = JSchemaType.Array;
            schema.Items.Add(new JSchema
            {
                Type = JSchemaType.Integer
            });

            SchemaValidationEventArgs a = null;

            StringWriter   sw     = new StringWriter();
            JsonTextWriter writer = new JsonTextWriter(sw);

            writer.Formatting = Formatting.Indented;
            JSchemaValidatingWriter validatingWriter = new JSchemaValidatingWriter(writer);

            validatingWriter.Schema = schema;
            validatingWriter.ValidationEventHandler += (sender, args) => { a = args; };

            validatingWriter.WriteStartArray();

            validatingWriter.WriteValue((object)"string");
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got String. Path '[0]'.", a.Message);
            Assert.AreEqual("string", a.ValidationError.Value);
            Assert.AreEqual("#/items", a.ValidationError.SchemaId.ToString());
            a = null;

            validatingWriter.WriteValue((object)null);
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got Null. Path '[1]'.", a.Message);
            Assert.AreEqual(null, a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue((object)'e');
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got String. Path '[2]'.", a.Message);
            Assert.AreEqual("e", a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue((object)true);
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got Boolean. Path '[3]'.", a.Message);
            Assert.AreEqual(true, a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue((object)null);
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got Null. Path '[4]'.", a.Message);
            Assert.AreEqual(null, a.ValidationError.Value);
            a = null;

            validatingWriter.WriteNull();
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got Null. Path '[5]'.", a.Message);
            Assert.AreEqual(null, a.ValidationError.Value);
            a = null;

            validatingWriter.WriteUndefined();
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got Undefined. Path '[6]'.", a.Message);
            Assert.AreEqual(null, a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue((object)(ushort)12);
            Assert.IsNull(a);
            validatingWriter.WriteValue((object)(short)12);
            Assert.IsNull(a);
            validatingWriter.WriteValue((object)(byte)12);
            Assert.IsNull(a);
            validatingWriter.WriteValue((object)(sbyte)12);
            Assert.IsNull(a);
            validatingWriter.WriteValue((object)(long)12);
            Assert.IsNull(a);
            validatingWriter.WriteValue((object)(ulong)12);
            Assert.IsNull(a);
            validatingWriter.WriteValue((object)(int)12);
            Assert.IsNull(a);
            validatingWriter.WriteValue((object)(uint)12);
            Assert.IsNull(a);

            validatingWriter.WriteValue((object)1.1m);
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got Number. Path '[15]'.", a.Message);
            Assert.AreEqual(1.1m, (decimal)a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue((object)1.1d);
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got Number. Path '[16]'.", a.Message);
            Assert.AreEqual(1.1d, (double)a.ValidationError.Value, 0.0001);
            a = null;

            validatingWriter.WriteValue((object)1.1f);
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got Number. Path '[17]'.", a.Message);
            Assert.AreEqual(1.1f, (float)a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue((object)new Uri("http://test.test"));
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got String. Path '[18]'.", a.Message);
            Assert.AreEqual("http://test.test", a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue((object)TimeSpan.FromMinutes(1.0));
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got String. Path '[19]'.", a.Message);
            Assert.AreEqual("00:01:00", a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue((object)new Guid("3D1A74E8-0B2D-43F2-9D55-2E9DD4A1598E"));
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got String. Path '[20]'.", a.Message);
            Assert.AreEqual("3d1a74e8-0b2d-43f2-9d55-2e9dd4a1598e", a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue((object)Encoding.UTF8.GetBytes("Hello world."));
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got String. Path '[21]'.", a.Message);
            Assert.AreEqual("SGVsbG8gd29ybGQu", a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue((object)new DateTimeOffset(2000, 12, 2, 5, 6, 2, TimeSpan.Zero));
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got String. Path '[22]'.", a.Message);
            Assert.AreEqual("2000-12-02T05:06:02+00:00", a.ValidationError.Value);
            a = null;

            validatingWriter.WriteValue((object)new DateTime(2000, 12, 2, 5, 6, 2, DateTimeKind.Utc));
            Assert.IsNotNull(a);
            StringAssert.AreEqual("Invalid type. Expected Integer but got String. Path '[23]'.", a.Message);
            Assert.AreEqual("2000-12-02T05:06:02Z", a.ValidationError.Value);
            a = null;

            validatingWriter.WriteEndArray();
            Assert.IsNull(a);

            validatingWriter.Flush();

            string json = sw.ToString();

            StringAssert.AreEqual(@"[
  ""string"",
  null,
  ""e"",
  true,
  null,
  null,
  undefined,
  12,
  12,
  12,
  12,
  12,
  12,
  12,
  12,
  1.1,
  1.1,
  1.1,
  ""http://test.test"",
  ""00:01:00"",
  ""3d1a74e8-0b2d-43f2-9d55-2e9dd4a1598e"",
  ""SGVsbG8gd29ybGQu"",
  ""2000-12-02T05:06:02+00:00"",
  ""2000-12-02T05:06:02Z""
]", json);
        }