public void CreateComplexDecorateObjectsTest()
        {
            string[] bindingPropertyNames = new string[] { "Name", "SubObject.Category", "Properties[\"Ext\"].Category", "[\"Com\"].Category", "[\"Com\"].Description" };
            CodeDomTestObject fixture = new CodeDomTestObject
            {
                Name = "Eunge",
                SubObject = new SubCodeDomTestObject { Category = "NUnit", Description = "Desc" },
            };

            fixture["Com"] = new SubCodeDomTestObject { Category = "Com.NUnit", Description = "Com.Desc" };
            fixture.Properties["Ext"] = new SubCodeDomTestObject { Category = "Ext.NUnit", Description = "Ext.Desc" };

            Collection<PropertyDefinition> configs = new Collection<PropertyDefinition>();
            // Add wrappers for original properties
            Dictionary<string, string> cachedFieldNames = new Dictionary<string,string>();
            int index = 0;
            foreach (string bindingPropertyName in bindingPropertyNames)
            {
                PropertyDefinition config = new PropertyDefinition(typeof(string))
                {
                    PropertyName = bindingPropertyName,
                    NewPropertyName = FieldNameTransformUtility.DataBoundFieldName(bindingPropertyName, index++),
                };

                cachedFieldNames[bindingPropertyName]=config.NewPropertyName;
                configs.Add(config);
            }

            IEnumerable outputs = ClassDecorator.CreateDecorateObjects(new[] { fixture }, configs);
            object outputObject = outputs.Cast<object>().First();
            Assert.AreEqual("Eunge", DataBinder.Eval(outputObject, cachedFieldNames["Name"]));
            Assert.AreEqual("NUnit", DataBinder.Eval(outputObject, cachedFieldNames["SubObject.Category"]));
            Assert.AreEqual("Ext.NUnit", DataBinder.Eval(outputObject, cachedFieldNames["Properties[\"Ext\"].Category"]));
            Assert.AreEqual("Com.NUnit", DataBinder.Eval(outputObject, cachedFieldNames["[\"Com\"].Category"]));
            Assert.AreEqual("Com.Desc", DataBinder.Eval(outputObject, cachedFieldNames["[\"Com\"].Description"]));
        }
        public void CreateDecorateObjectsForTypeWithDictionaryPropertyTest()
        {
            CodeDomTestObject obj1 = new CodeDomTestObject { Name = "Eunge" };
            obj1.Properties["AnnualPackage"] = 210000;
            obj1.Properties["Birthday"] = new DateTime(1982, 2, 7);
            obj1.Properties["Position"] = "Engineer";

            IEnumerable results = ClassDecorator.CreateDecorateObjects(new[] { obj1 }, new[]
                {
                    new PropertyDefinition(typeof(string)) { PropertyName = "Name" },
                    new PropertyDefinition(typeof(int))
                    {
                        PropertyName = @"Properties[""AnnualPackage""]",
                        NewPropertyName = FieldNameTransformUtility.DataBoundFieldName(@"Properties[""AnnualPackage""]", 1),
                    },
                    new PropertyDefinition(typeof(DateTime))
                    {
                        PropertyName = @"Properties[""Birthday""]",
                        NewPropertyName = FieldNameTransformUtility.DataBoundFieldName(@"Properties[""Birthday""]", 2),
                    },
                    new PropertyDefinition(typeof(string))
                    {
                        PropertyName = @"Properties[""Position""]",
                        NewPropertyName = FieldNameTransformUtility.DataBoundFieldName(@"Properties[""Position""]", 3),
                    }
                });

            IEnumerable<object> returnObjects = results.Cast<object>();
            Assert.IsNotNull(returnObjects);
            Assert.AreEqual(1, returnObjects.Count());

            IObjectWrapper objectWrapper = new ObjectWrapper(returnObjects.First());
            Assert.AreEqual("Eunge", objectWrapper.GetPropertyValue("Name"));

            string positionPropertyName = FieldNameTransformUtility.DataBoundFieldName(@"Properties[""Position""]", 3);
            Assert.AreEqual("Engineer", objectWrapper.GetPropertyValue(positionPropertyName));
        }