public void CopyProperties_TypedWithDictionary()
        {
            var user = new PrivateOwner
            {
                FirstName = "Timmy",
                MyStrings = new Dictionary <string, string> {
                    { "A", "ABBA" }, { "B", "ACDC" }
                },
                MyIntegers = new Dictionary <int, int> {
                    { 1, 111 }, { 2, 222 }
                }
            };

            var patchData = new ExpandoObject();
            var items     = patchData as IDictionary <string, object>;

            items.Add("MyStrings", new Dictionary <string, string> {
                { "C", "CEEC" },
            });
            items.Add("MyIntegers", new Dictionary <int, int> {
                { 3, 333 }
            });

            ObjectExtensions.CopyProperties(patchData, user);
            Assert.Equal("CEEC", user.MyStrings["C"]);
            Assert.Equal(333, user.MyIntegers[3]);
        }
        public void CopyProperties_TypedArrayValueTypes()
        {
            var item = new PrivateOwner
            {
                FirstName = "Theodor",
                MyValues  = new List <int> {
                    1, 2, 3
                }
            };

            ObjectExtensions.CopyProperties(new { MyValues = new List <int> {
                                                      4, 5, 6, 7
                                                  } }, item);
            Assert.Equal(4, item.MyValues[0]);
            Assert.Equal(7, item.MyValues[3]);
        }
        public void CopyProperties_TypedExpandoSource()
        {
            var item = new PrivateOwner();

            item.FirstName = "Theodor";
            item.MyValues  = new List <int> {
            };

            var source = new ExpandoObject();
            var items  = source as IDictionary <string, object>;

            items.Add("FirstName", "Alter");
            items.Add("MyValues", new List <int> {
                1, 2
            });

            ObjectExtensions.CopyProperties(source, item);
            Assert.Equal(1, item.MyValues[0]);
            Assert.Equal(2, item.MyValues[1]);
        }