예제 #1
0
        public void Write_NullableContainer()
        {
            var obj = new NullableContainer()
            {
                TestProp = 5
            };

            Assert.AreEqual(ReadXml("NullableContainer.xml").Trim(), XamlServices.Save(obj), "#1");
        }
예제 #2
0
        public void Read_NullableContainer()
        {
            var obj = new NullableContainer()
            {
                TestProp = 5
            };
            var xr = new XamlObjectReader(obj);

            Read_NullableContainer(xr);
        }
예제 #3
0
        public void NullableContainer()
        {
            var xt = sctx.GetXamlType(typeof(NullableContainer));

            Assert.IsFalse(xt.IsGeneric, "#1");
            Assert.IsTrue(xt.IsNullable, "#2");
            var xm = xt.GetMember("TestProp");

            Assert.IsTrue(xm.Type.IsGeneric, "#3");
            Assert.IsTrue(xm.Type.IsNullable, "#4");
            Assert.AreEqual("clr-namespace:System;assembly=mscorlib", xm.Type.PreferredXamlNamespace, "#5");
            Assert.AreEqual(1, xm.Type.TypeArguments.Count, "#6");
            Assert.AreEqual(XamlLanguage.Int32, xm.Type.TypeArguments [0], "#7");
            Assert.IsNotNull(xm.Type.TypeConverter, "#8");
            Assert.IsNotNull(xm.Type.TypeConverter.ConverterInstance, "#9");

            var obj = new NullableContainer();

            xm.Invoker.SetValue(obj, 5);
            xm.Invoker.SetValue(obj, null);
        }