Exemplo n.º 1
0
        public void SkipRegisteryIfNotJToken()
        {
            var schema = new Schema();
            var type   = typeof(string);

            var addExample = new AddSchemaExamples();

            addExample.Apply(schema, reg, type);

            Assert.AreEqual(0, reg.Definitions.Count());
            Assert.AreEqual(null, schema.@ref);
            Assert.AreEqual(null, schema.type);
        }
Exemplo n.º 2
0
        public void SkipSecondJTokenTypeButSetRef()
        {
            var schema = new Schema();
            var type   = typeof(JToken);

            reg.Definitions.Add("JSON", new Schema());

            var addExample = new AddSchemaExamples();

            addExample.Apply(schema, reg, type);

            Assert.AreEqual(1, reg.Definitions.Count());

            Assert.AreEqual("#/definitions/JSON", schema.@ref);
            Assert.AreEqual(null, schema.type);
        }
Exemplo n.º 3
0
        public void AddFirstJTokenType()
        {
            var schema = new Schema();
            var type   = typeof(JToken);

            var addExample = new AddSchemaExamples();

            addExample.Apply(schema, reg, type);

            Assert.AreEqual(1, reg.Definitions.Count());
            Assert.AreEqual("string", reg.Definitions["JSON"].properties["Column1"].type);
            Assert.AreEqual("integer", reg.Definitions["JSON"].properties["Column2"].type);
            Assert.AreEqual(0, reg.Definitions["JSON"].properties["Column2"].@default);

            Assert.AreEqual("#/definitions/JSON", schema.@ref);
            Assert.AreEqual(null, schema.type);
        }