Ejemplo n.º 1
0
        public void GenericTypeDynamicObjectFromSubFactoryTest()
        {
            dynamic sampleObject = new DynamicModel();

            sampleObject.Name = "Nu";
            sampleObject.Age  = 12;

            var v = ObjectVisitor.Dynamic.CreateForDynamicObject((DynamicModel)sampleObject);

            Assert.Equal("Nu", v.GetValue <string>("Name"));
            Assert.Equal(12, v.GetValue <int>("Age"));
        }
Ejemplo n.º 2
0
        public void DirectTypeDynamicObjectTest()
        {
            dynamic sampleObject = new DynamicModel();

            sampleObject.Name = "Nu";
            sampleObject.Age  = 12;

            var v = ObjectVisitor.Create(typeof(DynamicModel), (DynamicModel)sampleObject);

            Assert.Equal("Nu", v.GetValue <string>("Name"));
            Assert.Equal(12, v.GetValue <int>("Age"));
        }