public void TestSerializeStringSchema() { IValueSchema<string> schema = new StringSchema {AllowNull = true, DefaultValue = "abc", MaxLength = 100, MinLength = 2, PossibleValues = new[]{"abc","def"} }; JsonSchemaSerializationVisitor visitor=new JsonSchemaSerializationVisitor(); schema.Accept(visitor); Assert.AreEqual(typeof(string),visitor.ValueType); Assert.AreEqual(typeof(StringSchema),visitor.SchemaType); Assert.IsNotNull(visitor.JsonValue); Assert.AreNotEqual(0,visitor.JsonValue.Length); }
public void TestSerializeStringSchema() { IValueSchema <string> schema = new StringSchema { AllowNull = true, DefaultValue = "abc", MaxLength = 100, MinLength = 2, PossibleValues = new[] { "abc", "def" } }; SchemaJsonSerializationVisitor visitor = new SchemaJsonSerializationVisitor(); schema.Accept(visitor); Assert.AreEqual(typeof(string), visitor.ValueType); Assert.AreEqual(typeof(StringSchema), visitor.SchemaType); Assert.IsNotNull(visitor.JsonValue); Assert.AreNotEqual(0, visitor.JsonValue.Length); }
public void TestDeserializeStringSchema() { IValueSchema <string> schema = new StringSchema { AllowNull = true, DefaultValue = "abc", MaxLength = 100, MinLength = 2, PossibleValues = new[] { "abc", "def" } }; SchemaJsonSerializationVisitor visitor = new SchemaJsonSerializationVisitor(); schema.Accept(visitor); IValueSchema <object> vs = JsonSchemaDeserializer.Deserialize(visitor.SchemaType, visitor.JsonValue); Assert.IsNotNull(vs); Assert.AreEqual(typeof(string), vs.Type); }