示例#1
0
        public void SimpleTest()
        {
            var obj1 = SettingsMapper.Map<MySettings>();

            var obj2 = new MySettings();
            SettingsMapper.Map(obj2);

            var obj3 = (MySettings)SettingsMapper.Map(typeof(MySettings), null);

            var obj4 = new MySettings();
            SettingsMapper.Map(obj4);

            Assert.AreNotEqual(obj1, obj2);
            Assert.AreNotEqual(obj1, obj3);
            Assert.AreNotEqual(obj1, obj4);

            Check(obj1);
            Check(obj2);
            Check(obj3);
            Check(obj4);
        }
示例#2
0
        public void Check(MySettings obj)
        {
            Assert.AreEqual(obj.Name, "TestName");
            Assert.AreEqual(obj.Value, "Hello");
            Assert.AreEqual(obj.Year, 2011);

            Assert.AreEqual(obj.InnerSettings.True, true);
            Assert.AreEqual(obj.InnerSettings.False, false);

            Assert.AreEqual(obj.InnerSettings.Yes, true);
            Assert.AreEqual(obj.InnerSettings.No, false);

            Assert.AreEqual(obj.Double, 176.23);
            Assert.AreEqual(obj.Decimal, 132476.4523);
        }