public void TestSerializeGroupsSchema() { IValueSchema <string> schema = new GroupsSchema() { AllowNull = false, 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(GroupsSchema), visitor.SchemaType); Assert.IsNotNull(visitor.JsonValue); Assert.AreNotEqual(0, visitor.JsonValue.Length); }
public void TestDeserializeGroupsSchema() { IValueSchema <string> schema = new GroupsSchema { 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); }