Ejemplo n.º 1
0
        public void GetAllPropertyToDictionary()
        {
            var test = new TestClass();
            var anon = new { Str = "Test2", Int = 9000, Date = new DateTime(1900, 1, 1) };

            test.StringProperty = "Test";
            test.IntProperty = 9999;
            test.DateTimeProperty = new DateTime(2000, 1, 1);

            var dic1 = test.GetAllPropertyToDictionary();
            var dic2 = anon.GetAllPropertyToDictionary();

            Assert.AreEqual<string>((string)dic1["StringProperty"], "Test");
            Assert.AreEqual<int>((int)dic1["IntProperty"], 9999);
            Assert.AreEqual<DateTime>((DateTime)dic1["DateTimeProperty"], new DateTime(2000, 1, 1));

            Assert.AreEqual<string>((string)dic2["Str"], "Test2");
            Assert.AreEqual<int>((int)dic2["Int"], 9000);
            Assert.AreEqual<DateTime>((DateTime)dic2["Date"], new DateTime(1900, 1, 1));
        }