コード例 #1
0
        public void IterateOverDynamicPropertiesTest()
        {
            var ex = new ExpandoInstance
            {
                Name    = "Name",
                Entered = DateTime.Now
            };

            dynamic exd = ex;

            exd.Company  = "Company";
            exd.Accesses = 10;

            // Dictionary pseudo implementation
            ex["Count"] = 10;
            ex["Type"]  = "MyType";

            // Dictionary Count - 2 dynamic props added
            Assert.IsTrue(ex.Properties.Count == 4);

            // iterate over all properties
            foreach (KeyValuePair <string, object> prop in exd.GetProperties(true))
            {
                Trace.WriteLine(prop.Key + " " + prop.Value);
            }
        }
コード例 #2
0
        public void PropertyAsIndexerTest()
        {
            // Set standard properties
            var ex = new ExpandoInstance
            {
                Name    = "Name",
                Entered = DateTime.Now
            };

            Assert.AreEqual(ex.Name, ex["Name"]);
            Assert.AreEqual(ex.Entered, ex["Entered"]);
        }
コード例 #3
0
        public void DynamicAccessToPropertyTest()
        {
            // Set standard properties
            var ex = new ExpandoInstance
            {
                Name    = "Name",
                Entered = DateTime.Now
            };

            // turn into dynamic
            dynamic exd = ex;

            // Dynamic can access
            Assert.AreEqual(ex.Name, exd.Name);
            Assert.AreEqual(ex.Entered, exd.Entered);
        }
コード例 #4
0
        public void AddAndReadDynamicIndexersTest()
        {
            var ex = new ExpandoInstance
            {
                Name    = "Name",
                Entered = DateTime.Now
            };

            ex["Address"]   = "Address 123";
            ex["Contacted"] = true;

            dynamic exd = ex;

            Assert.AreEqual(exd.Address, ex["Address"]);
            Assert.AreEqual(exd.Contacted, true);
        }
コード例 #5
0
        public void MixInObjectInstanceTest()
        {
            // Create expando an mix-in second objectInstanceTest
            var ex = new ExpandoInstance(new Address())
            {
                Name    = "Name",
                Entered = DateTime.Now
            };

            // create dynamic
            dynamic exd = ex;

            // values should show Addresses initialized values (not null)
            Trace.WriteLine(string.Format("address:{0}", exd.FullAddress as string));
            Trace.WriteLine(string.Format("email:{0}", exd.Email as string));
            Trace.WriteLine(string.Format("phone:{0}", exd.Phone as string));
        }
コード例 #6
0
ファイル: ExpandoTests.cs プロジェクト: vip32/Xtricate
        public void AddAndReadDynamicIndexersTest()
        {
            var ex = new ExpandoInstance
            {
                Name = "Name",
                Entered = DateTime.Now
            };

            ex["Address"] = "Address 123";
            ex["Contacted"] = true;

            dynamic exd = ex;

            Assert.AreEqual(exd.Address, ex["Address"]);
            Assert.AreEqual(exd.Contacted, true);
        }
コード例 #7
0
ファイル: ExpandoTests.cs プロジェクト: vip32/Xtricate
        public void PropertyAsIndexerTest()
        {
            // Set standard properties
            var ex = new ExpandoInstance
            {
                Name = "Name",
                Entered = DateTime.Now
            };

            Assert.AreEqual(ex.Name, ex["Name"]);
            Assert.AreEqual(ex.Entered, ex["Entered"]);
        }
コード例 #8
0
ファイル: ExpandoTests.cs プロジェクト: vip32/Xtricate
        public void MixInObjectInstanceTest()
        {
            // Create expando an mix-in second objectInstanceTest
            var ex = new ExpandoInstance(new Address())
            {
                Name = "Name",
                Entered = DateTime.Now
            };

            // create dynamic
            dynamic exd = ex;

            // values should show Addresses initialized values (not null)
            Trace.WriteLine(string.Format("address:{0}", exd.FullAddress as string));
            Trace.WriteLine(string.Format("email:{0}", exd.Email as string));
            Trace.WriteLine(string.Format("phone:{0}", exd.Phone as string));
        }
コード例 #9
0
ファイル: ExpandoTests.cs プロジェクト: vip32/Xtricate
        public void IterateOverDynamicPropertiesTest()
        {
            var ex = new ExpandoInstance
            {
                Name = "Name",
                Entered = DateTime.Now
            };

            dynamic exd = ex;
            exd.Company = "Company";
            exd.Accesses = 10;

            // Dictionary pseudo implementation
            ex["Count"] = 10;
            ex["Type"] = "MyType";

            // Dictionary Count - 2 dynamic props added
            Assert.IsTrue(ex.Properties.Count == 4);

            // iterate over all properties
            foreach (KeyValuePair<string, object> prop in exd.GetProperties(true))
            {
                Trace.WriteLine(prop.Key + " " + prop.Value);
            }
        }
コード例 #10
0
ファイル: ExpandoTests.cs プロジェクト: vip32/Xtricate
        public void DynamicAccessToPropertyTest()
        {
            // Set standard properties
            var ex = new ExpandoInstance
            {
                Name = "Name",
                Entered = DateTime.Now
            };

            // turn into dynamic
            dynamic exd = ex;

            // Dynamic can access
            Assert.AreEqual(ex.Name, exd.Name);
            Assert.AreEqual(ex.Entered, exd.Entered);
        }