상속: DynamicMixin, IMapper
예제 #1
0
 public void DynamicMixinCanGetPropertyType()
 {
     dynamic foo = new FooDynamic();
     foo.Name = "Foo";
     foo.Boo = 1;
     var fooMixin = (IMixin) foo;
     Assert.AreEqual(typeof (string), fooMixin.GetPropertyType("Name"));
     Assert.AreEqual(typeof (int), fooMixin.GetPropertyType("Boo"));
     foo.Boo = DateTime.Now;
     Assert.AreEqual(typeof (DateTime), fooMixin.GetPropertyType("Boo"));
     foo.Boo = null;
     Assert.AreEqual(null, fooMixin.GetPropertyType("Boo"));
 }
예제 #2
0
 public void DynamicMixinCanMapInShapshotMode()
 {
     dynamic foo = new FooDynamic();
     foo.Name = "Foo";
     dynamic bar = new BarDynamic();
     bar.Name = "Bar";
     bar.Tag = 1;
     bar.Boo = "boo";
     ((IMapper) foo).MapTo((IMapper) bar, true);
     Assert.AreEqual("Foo", bar.Name);
     Assert.AreEqual(null, bar.Tag);
     Assert.AreEqual(null, bar.Boo);
 }
예제 #3
0
 public void DynamicMixinCanMap()
 {
     dynamic foo = new FooDynamic();
     foo.Name = "Foo";
     foo.Age = 1;
     foo.Tag = 1;
     dynamic bar = new BarDynamic();
     bar.Name = "Bar";
     bar.Age = 2;
     bar.Tag = "tag";
     ((IMapper) foo).MapTo((IMapper) bar);
     Assert.AreEqual("Foo", bar.Name);
     Assert.AreEqual(1, bar.Age);
     Assert.AreEqual("tag", bar.Tag);
 }