public void GetProperties_ReturnsPropertiesFromDataDictionary()
        {
            IDictionary<string, object> data = new Dictionary<string, object>();
            data["Property1"] = "value1";
            data["Property2"] = 2;

            DictionaryTypeDescriptor typeDescriptor = new DictionaryTypeDescriptor(data);

            PropertyDescriptorCollection properties = typeDescriptor.GetProperties();
            Assert.That(properties[0].Name, Is.EqualTo("Property1"));
            Assert.That(properties[1].Name, Is.EqualTo("Property2"));
        }
        public void GetProperties_TypeOmitted_UsesObjectType()
        {
            IDictionary<string, object> data = new Dictionary<string, object>();
            data["Property1"] = "value1";
            data["Property2"] = 2;

            DictionaryTypeDescriptor typeDescriptor = new DictionaryTypeDescriptor(data);

            PropertyDescriptorCollection properties = typeDescriptor.GetProperties();
            Assert.That(properties[0].Name, Is.EqualTo("Property1"));
            Assert.That(properties[0].PropertyType, Is.EqualTo(typeof(object)));
            Assert.That(properties[1].Name, Is.EqualTo("Property2"));
            Assert.That(properties[1].PropertyType, Is.EqualTo(typeof(object)));
        }
        public void GetProperties_ReturnsPropertiesFromDataDictionary()
        {
            var data = new Dictionary <string, object>();

            data["Property1"] = "value1";
            data["Property2"] = 2;

            var typeDescriptor = new DictionaryTypeDescriptor(data);

            var properties = typeDescriptor.GetProperties();

            properties[0].Name.Should().Be("Property1");
            properties[1].Name.Should().Be("Property2");
        }
        public void GetProperties_TypeOmitted_UsesObjectType()
        {
            var data = new Dictionary <string, object>();

            data["Property1"] = "value1";
            data["Property2"] = 2;

            var typeDescriptor = new DictionaryTypeDescriptor(data);

            var properties = typeDescriptor.GetProperties();

            properties[0].Name.Should().Be("Property1");
            properties[0].PropertyType.Should().Be(typeof(object));
            properties[1].Name.Should().Be("Property2");
            properties[1].PropertyType.Should().Be(typeof(object));
        }
        public void GetProperties_TypeIncluded_UsesSpecifiedType()
        {
            IDictionary<string, object> data = new Dictionary<string, object>();
            data["Property1"] = "value1";
            data["Property2"] = 2;

            IDictionary<string, Type> types = new Dictionary<string, Type>();
            types["Property1"] = typeof(string);
            types["Property2"] = typeof(int);

            DictionaryTypeDescriptor typeDescriptor = new DictionaryTypeDescriptor(data, types);

            PropertyDescriptorCollection properties = typeDescriptor.GetProperties();
            Assert.That(properties[0].Name, Is.EqualTo("Property1"));
            Assert.That(properties[0].PropertyType, Is.EqualTo(typeof(string)));
            Assert.That(properties[1].Name, Is.EqualTo("Property2"));
            Assert.That(properties[1].PropertyType, Is.EqualTo(typeof(int)));
        }
        public void GetProperties_TypeIncluded_UsesSpecifiedType()
        {
            var data = new Dictionary <string, object>();

            data["Property1"] = "value1";
            data["Property2"] = 2;

            var types = new Dictionary <string, Type>();

            types["Property1"] = typeof(string);
            types["Property2"] = typeof(int);

            var typeDescriptor = new DictionaryTypeDescriptor(data, types);

            var properties = typeDescriptor.GetProperties();

            properties[0].Name.Should().Be("Property1");
            properties[0].PropertyType.Should().Be(typeof(string));
            properties[1].Name.Should().Be("Property2");
            properties[1].PropertyType.Should().Be(typeof(int));
        }
        public void PropertySet_RaisesPropertyChangedEvent()
        {
            var data = new Dictionary <string, object>();

            data["Property1"] = "value1";
            data["Property2"] = "value2";

            string propertyChanged = null;

            var descriptor = new DictionaryTypeDescriptor(data);

            descriptor.PropertyChanged += (s, e) =>
            {
                propertyChanged = e.PropertyName;
            };

            var properties = descriptor.GetProperties();

            properties[0].SetValue(descriptor, "modified");

            data["Property1"].Should().Be("modified");
            propertyChanged.Should().Be("Property1");
        }
        public void PropertyReset_RaisesPropertyChangedEvent()
        {
            var data = new Dictionary<string, object>();
            data["Property1"] = "value1";
            data["Property2"] = "value2";

            string propertyChanged = null;

            var descriptor = new DictionaryTypeDescriptor(data);
            descriptor.PropertyChanged += (s, e) =>
            {
                propertyChanged = e.PropertyName;
            };

            var properties = descriptor.GetProperties();
            properties[0].ResetValue(descriptor);

            Assert.That(data["Property1"], Is.EqualTo(null));
            Assert.That(propertyChanged, Is.EqualTo("Property1"));
        }