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