Exemple #1
0
        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);
        }
Exemple #2
0
        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());
        }
Exemple #3
0
        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);
        }