public void TestBindTo() { IPropertyBinder<ControlTestClass, string> binder = new PropertyBinder<ControlTestClass, string>( z => z.Text, (cls, action) => cls.TextChanged += (sender, args) => action()); var instance = new ControlTestClass { Text = "First" }; TestBindableProperty(instance, binder.BindTo(instance)); binder = new PropertyBinder<ControlTestClass, int, string>( z => z.Number, (cls, action) => cls.NumberChanged += (sender, args) => action(), new DataConverter<int, string>(Helper.ToText, Helper.ToInt32)); instance = new ControlTestClass { Number = 1 }; var property = binder.BindTo(instance); Assert.Equal("First", property.Value); Assert.Equal(instance.Number.ToText(), property.Value); instance.Number = 2; Assert.Equal("Second", property.Value); property.Value = "Third"; Assert.Equal("Third", instance.Number.ToText()); int numberChangedCount = 0; int propertyChangedCount = 0; instance.NumberChanged += (sender, args) => numberChangedCount++; property.PropertyChanged += (sender, args) => { Assert.Equal("Number", args.PropertyName); propertyChangedCount++; }; instance.Number = 4; Assert.Equal(1, numberChangedCount); Assert.Equal(1, propertyChangedCount); property.Value = "Fifth"; Assert.Equal(2, numberChangedCount); Assert.Equal(2, propertyChangedCount); }