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>(); }); }
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>(); }); }
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); }