public void TestUnwrapObjectPassingInvalidObject() { StringSchema schema = new StringSchema(); IValueSchema <object> wrapper = schema.Wrap(); Assert.IsNotNull(wrapper); Assert.AreEqual(typeof(string), wrapper.Type); Assert.Throws <InvalidCastException>(() => { wrapper.UnwrapRefType <ArrayList>(); }); }
public void TestUnwrapObject() { StringSchema schema = new StringSchema(); IValueSchema <object> wrapper = schema.Wrap(); Assert.IsNotNull(wrapper); Assert.AreEqual(typeof(string), wrapper.Type); IValueSchema <string> vs = wrapper.UnwrapRefType <string>(); Assert.IsNotNull(vs); StringSchema stringSchema = vs as StringSchema; Assert.IsNotNull(stringSchema); }
public void TestStringDeSerializeProperties() { JsonPropertySerializer serializer = new JsonPropertySerializer(new PropertySchemaFactory()); StringSchema schema = new StringSchema { MaxLength = 100, MinLength = 1, DefaultValue = "hello" }; PropertyElement element = serializer.Serialize("hello", schema.Wrap()); Assert.IsNotNull(element); Assert.AreEqual(typeof(StringSchema).FullName, element.Schema.SchemaType); Assert.AreEqual(SerializationTypeHint.String, element.SerializationHint); Assert.AreEqual("hello", element.Value); IValueSchema <object> vs = serializer.DeserializeSchema(element.Schema); Assert.IsNotNull(vs); IValueSchema <string> strSchema = vs.UnwrapRefType <string>(); Assert.IsNotNull(strSchema); }