public void NullableEnumTest()
        {
            SourceObject so = new SourceObject();

            Object5 b = Map.ObjectToObject <Object5>(so);

            Assert.AreEqual(Enum2.Value1, b.test);
        }
示例#2
0
        public void Test5()
        {
            Object5 o = (Object5)Map.ObjectToObject(new SourceObject(), typeof(Object5), 11, 22, 44);

            Assert.AreEqual(77, o.Int00);
            Assert.AreEqual(11, o.Int11);
            Assert.AreEqual(22, o.Int22);
            Assert.AreEqual(30, o.Int3);
            Assert.AreEqual(44, o.Int44);
        }
        public void OMM_SubConfig_Object_Conditional_SubConfigure_NewType()
        {
            Object5 obj = new Object5()
            {
                Value = 50
            };

            string value1 = ObjectMessageMap.GetMessage(obj);
            string value2 = ObjectMessageMap.GetMessage(typeof(Object5));

            Assert.AreEqual("Bullseye!", value1);
            Assert.AreEqual("", value2);
        }
        public void OMM_SubConfig_Object_Conditional_Default_UseMessage_ValueNotFound()
        {
            Object5 obj = new Object5()
            {
                Value = 51
            };

            string value1 = ObjectMessageMap.GetMessage(obj);
            string value2 = ObjectMessageMap.GetMessage(typeof(Object5));

            Assert.AreEqual("", value1);
            Assert.AreEqual("", value2);
        }
示例#5
0
        public void TestPrimitive()
        {
            ObjectMapper om = Map.GetObjectMapper(typeof(Object5));

            Object5 o = (Object5)om.CreateInstance();

            om.SetValue(o, "Int1", null);
            om.SetValue(o, "Int2", null);
            om.SetValue(o, "Int3", null);

            Assert.AreEqual(0, o.Int1);
            Assert.AreEqual(0, o.Int2);
            Assert.AreEqual(int.MinValue, o.Int3);

            Assert.IsNotNull(om.GetValue(o, "Int1"));
            Assert.IsNull(om.GetValue(o, "Int2"));
            Assert.IsNull(om.GetValue(o, "Int3"));
        }