Example #1
0
 public void TestUnwrapStructPassingObjecSchema()
 {
     StringSchema schema = new StringSchema();
     IValueSchema<object> wrapper = schema.Wrap();
     Assert.IsNotNull(wrapper);
     Assert.AreEqual(typeof(string), wrapper.Type);
     wrapper.UnwrapValueType<int>();
 }
Example #2
0
 public void TestUnwrapObjectPassingInvalidObject()
 {
     StringSchema schema = new StringSchema();
     IValueSchema<object> wrapper = schema.Wrap();
     Assert.IsNotNull(wrapper);
     Assert.AreEqual(typeof(string), wrapper.Type);
     wrapper.UnwrapRefType<ArrayList>();
 }
Example #3
0
 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 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 TestStringSerializeProperties()
        {
            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);
        }
        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);
        }
Example #7
0
 public void TestWrapObject()
 {
     StringSchema  schema=new StringSchema{AllowNull = true,DefaultValue = "Hello",PossibleValues = new[]{"one","two","Hello","Goodbye"}};
     IValueSchema<object> wrapper = schema.Wrap();
     Assert.IsNotNull(wrapper);
     Assert.AreEqual(typeof(string),wrapper.Type);
     Assert.IsTrue(wrapper.AllowNull);
     Assert.AreEqual("Hello",wrapper.DefaultValue);
     Assert.IsNotNull(wrapper.PossibleValues);
     Assert.AreEqual(4,wrapper.PossibleValues.Count());
     Assert.AreEqual("one",wrapper.PossibleValues.ElementAt(0));
     Assert.AreEqual("two", wrapper.PossibleValues.ElementAt(1));
     Assert.AreEqual("Hello", wrapper.PossibleValues.ElementAt(2));
     Assert.AreEqual("Goodbye", wrapper.PossibleValues.ElementAt(3));
 }
        public void TestWrapObject()
        {
            StringSchema schema = new StringSchema {
                AllowNull = true, DefaultValue = "Hello", PossibleValues = new[] { "one", "two", "Hello", "Goodbye" }
            };
            IValueSchema <object> wrapper = schema.Wrap();

            Assert.IsNotNull(wrapper);
            Assert.AreEqual(typeof(string), wrapper.Type);
            Assert.IsTrue(wrapper.AllowNull);
            Assert.AreEqual("Hello", wrapper.DefaultValue);
            Assert.IsNotNull(wrapper.PossibleValues);
            Assert.AreEqual(4, wrapper.PossibleValues.Count());
            Assert.AreEqual("one", wrapper.PossibleValues.ElementAt(0));
            Assert.AreEqual("two", wrapper.PossibleValues.ElementAt(1));
            Assert.AreEqual("Hello", wrapper.PossibleValues.ElementAt(2));
            Assert.AreEqual("Goodbye", wrapper.PossibleValues.ElementAt(3));
        }
        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);
        }
        public void TestStringDeSerializeProperties()
        {
            JsonPropertySerializer serializer = new JsonPropertySerializer(new PropertySchemaFactory());
            StringSchema schema = new StringSchema { MaxLength = 100, MinLength = 1, DefaultValue = "hello" };
            PropertyElement element = serializer.Serialize("key", "hello", schema.Wrap());
            Assert.IsNotNull(element);
            Assert.AreEqual(typeof(StringSchema).FullName, element.SchemaType);
            Assert.AreEqual(SerializationValueType.String, element.SerializationValueType);
            Assert.AreEqual("hello", element.ValString);

            IValueSchema<object> vs;
            object value = serializer.Deserialize(element, out vs);
            Assert.IsNotNull(vs);
            Assert.IsNotNull(value);
            IValueSchema<string> strSchema = vs.UnwrapRefType<string>();
            Assert.IsNotNull(strSchema);
        }
 public void TestStringSerializeProperties()
 {
     JsonPropertySerializer serializer=new JsonPropertySerializer(new PropertySchemaFactory());
     StringSchema schema=new StringSchema{MaxLength = 100,MinLength = 1, DefaultValue = "hello"};
     PropertyElement element = serializer.Serialize("key", "hello", schema.Wrap());
     Assert.IsNotNull(element);
     Assert.AreEqual(typeof(StringSchema).FullName,element.SchemaType);
     Assert.AreEqual(SerializationValueType.String,element.SerializationValueType);
     Assert.AreEqual("hello",element.ValString);
 }