Пример #1
0
        public void TestUnwrapStructPassingObjecSchema()
        {
            StringSchema          schema  = new StringSchema();
            IValueSchema <object> wrapper = schema.Wrap();

            Assert.IsNotNull(wrapper);
            Assert.AreEqual(typeof(string), wrapper.Type);
            Assert.Throws <InvalidCastException>(() =>
            {
                wrapper.UnwrapValueType <int>();
            });
        }
Пример #2
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>();
            });
        }
Пример #3
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);
        }