the examples for .Dynamic()

 [TestClass]
    public class DynamicTest
    {
        [TestMethod]
        public void dynamic_for_set_property_value()
        {
            var obj = new MockObject { Name = "dayi", Blog = "http://walkingboy.cnblogs.com", Location = "Xiamen" };

            var changedLocation = "Xiamen,China";
            obj.Dynamic().Location = changedLocation;

            Assert.AreEqual(changedLocation, obj.Location);
        }

        [TestMethod]
        public void dynamic_for_get_property_value()
        {
            var obj = new MockObject { Name = "dayi", Blog = "http://walkingboy.cnblogs.com", Location = "Xiamen" };

            Assert.AreEqual(obj.Location, obj.Dynamic().Location);
        }

        [TestMethod]
        public void dynamic_for_get_field_value()
        {
            var obj = new MockObject { Name = "dayi", Blog = "http://walkingboy.cnblogs.com", Location = "Xiamen" };

            Assert.AreEqual(obj.Country, obj.Dynamic().Country);
        }

        [TestMethod]
        public void dynamic_for_method()
        {
            var obj = new MockObject();

            Assert.AreEqual("Hi,world", obj.Dynamic().SayHello("world"));
        }
    }

Last edited Aug 29, 2010 at 12:18 PM by cnlangzi, version 1

Comments

No comments yet.