Ejemplo n.º 1
0
 public void TestUnrapStructPassingInvalidType()
 {
     IntSchema schema = new IntSchema { AllowNull = true, DefaultValue = 100, PossibleValues = new int?[] { 1, 2, 3 } };
     IValueSchema<object> wrapper = schema.Wrap();
     Assert.IsNotNull(wrapper);
     Assert.AreEqual(typeof(int?), wrapper.Type);
     wrapper.UnwrapValueType<DateTime>();
 }
Ejemplo n.º 2
0
 public void TestUnwrapStruct()
 {
     IntSchema schema = new IntSchema { AllowNull = true, DefaultValue = 100, PossibleValues = new int?[] { 1, 2, 3 } };
     IValueSchema<object> wrapper = schema.Wrap();
     Assert.IsNotNull(wrapper);
     Assert.AreEqual(typeof(int?), wrapper.Type);
     IValueSchema<int?> vs = wrapper.UnwrapValueType<int>();
     Assert.IsNotNull(vs);
     Assert.IsTrue(vs.AllowNull);
     Assert.AreEqual(100,vs.DefaultValue);
     IntSchema intSchema = vs as IntSchema;
     Assert.IsNotNull(intSchema);
 }
Ejemplo n.º 3
0
        public void TestUnrapStructPassingInvalidType()
        {
            IntSchema schema = new IntSchema {
                AllowNull = true, DefaultValue = 100, PossibleValues = new int?[] { 1, 2, 3 }
            };
            IValueSchema <object> wrapper = schema.Wrap();

            Assert.IsNotNull(wrapper);
            Assert.AreEqual(typeof(int?), wrapper.Type);
            Assert.Throws <InvalidCastException>(() =>
            {
                wrapper.UnwrapValueType <DateTime>();
            });
        }
Ejemplo n.º 4
0
        public void TestWrapStruct()
        {
            IntSchema schema = new IntSchema {
                AllowNull = true, DefaultValue = 100, PossibleValues = new int?[] { 1, 2, 3 }
            };
            IValueSchema <object> wrapper = schema.Wrap();

            Assert.IsNotNull(wrapper);
            Assert.AreEqual(typeof(int?), wrapper.Type);
            Assert.IsTrue(wrapper.AllowNull);
            Assert.AreEqual(100, wrapper.DefaultValue);
            Assert.IsNotNull(wrapper.PossibleValues);
            Assert.AreEqual(3, wrapper.PossibleValues.Count());
            Assert.AreEqual(1, wrapper.PossibleValues.ElementAt(0));
            Assert.AreEqual(2, wrapper.PossibleValues.ElementAt(1));
            Assert.AreEqual(3, wrapper.PossibleValues.ElementAt(2));
        }
Ejemplo n.º 5
0
        public void TestUnwrapStruct()
        {
            IntSchema schema = new IntSchema {
                AllowNull = true, DefaultValue = 100, PossibleValues = new int?[] { 1, 2, 3 }
            };
            IValueSchema <object> wrapper = schema.Wrap();

            Assert.IsNotNull(wrapper);
            Assert.AreEqual(typeof(int?), wrapper.Type);
            IValueSchema <int?> vs = wrapper.UnwrapValueType <int>();

            Assert.IsNotNull(vs);
            Assert.IsTrue(vs.AllowNull);
            Assert.AreEqual(100, vs.DefaultValue);
            IntSchema intSchema = vs as IntSchema;

            Assert.IsNotNull(intSchema);
        }
Ejemplo n.º 6
0
 public void TestWrapStruct()
 {
     IntSchema schema = new IntSchema{AllowNull = true,DefaultValue = 100,PossibleValues = new int?[]{1,2,3}};
     IValueSchema<object> wrapper = schema.Wrap();
     Assert.IsNotNull(wrapper);
     Assert.AreEqual(typeof(int?), wrapper.Type);
     Assert.IsTrue(wrapper.AllowNull);
     Assert.AreEqual(100,wrapper.DefaultValue);
     Assert.IsNotNull(wrapper.PossibleValues);
     Assert.AreEqual(3,wrapper.PossibleValues.Count());
     Assert.AreEqual(1,wrapper.PossibleValues.ElementAt(0));
     Assert.AreEqual(2, wrapper.PossibleValues.ElementAt(1));
     Assert.AreEqual(3, wrapper.PossibleValues.ElementAt(2));
 }