public void DependOnAttributeTest() { var myClass = new BindClass(); List <string> propertyList = new List <string>(); myClass.PropertyChanged += (se, ev) => { propertyList.Add(ev.PropertyName); }; myClass.MyPropertyIntAutoGetSet = 10; Assert.AreEqual(propertyList.Count, 2); Assert.AreEqual(myClass.MyDependedPropertyInt, myClass.MyPropertyIntAutoGetSet * myClass.MyPropertyIntAutoGetSet); }
public void ObservableTest() { var myClass = new BindClass(); List <string> propertyList = new List <string>(); myClass.PropertyChanged += (se, ev) => { propertyList.Add(ev.PropertyName); }; myClass.MyObservableProperty = new ObservableCollection <int>(); myClass.MyObservableProperty.Add(1); myClass.MyObservableProperty.Add(2); Assert.AreEqual(propertyList.Count, 6); Assert.AreEqual(myClass.MyObservablePropertyCount, myClass.MyObservableProperty.Sum()); }
public void ChangedObjectNotifyPropertyChangeTest() { var myClass = new BindClass(); List <string> propertyList = new List <string>(); myClass.PropertyChanged += (se, ev) => { propertyList.Add(ev.PropertyName); }; myClass.ChangedObjectNotifyPropertyChange(nameof(myClass.MyProperty), nameof(myClass.MyCommand)); myClass.ChangedObjectNotifyPropertyChange(() => myClass.MyCommand, nameof(myClass.MyPropertyByName)); myClass.MyProperty = "string"; Thread.Sleep(1000); Assert.AreEqual(propertyList.Count, 3); }