public void RaisePropertyChangedWithNoParametersTest_B251476()
        {
            BindableBaseTest bb           = new BindableBaseTest();
            int    propertyChangedCounter = 0;
            string propertyChangedArgs    = null;

            bb.PropertyChanged += (d, e) => {
                propertyChangedCounter++;
                propertyChangedArgs = e.PropertyName;
            };
            bb.RaisePropertyChanged(null);
            Assert.AreEqual(1, propertyChangedCounter);
            Assert.AreEqual(null, propertyChangedArgs);

            bb.RaisePropertyChanged(string.Empty);
            Assert.AreEqual(2, propertyChangedCounter);
            Assert.AreEqual(string.Empty, propertyChangedArgs);

            bb.RaisePropertyChanged();
            Assert.AreEqual(3, propertyChangedCounter);
            Assert.AreEqual(string.Empty, propertyChangedArgs);

            bb.RaisePropertiesChanged();
            Assert.AreEqual(4, propertyChangedCounter);
            Assert.AreEqual(string.Empty, propertyChangedArgs);

            bb.RaisePropertiesChanged(null);
            Assert.AreEqual(5, propertyChangedCounter);
            Assert.AreEqual(string.Empty, propertyChangedArgs);

            bb.RaisePropertiesChanged(string.Empty);
            Assert.AreEqual(6, propertyChangedCounter);
            Assert.AreEqual(string.Empty, propertyChangedArgs);
        }
        public void SetPropertyInvalidLambdaTest()
        {
            BindableBaseTest bb = new BindableBaseTest();

            Assert.Throws <ArgumentException>(() => { bb.SomeProperty4 = 150; });
            Assert.Throws <ArgumentException>(() => { bb.SomeProperty5 = 150; });
            Assert.Throws <ArgumentException>(() => { bb.SomeProperty6 = 150; });
        }
 public void RaisePropertyChangedWithNoParametersTest_B251476() {
     BindableBaseTest bb = new BindableBaseTest();
     bb.RaisePropertyChanged(null);
     bb.RaisePropertyChanged(string.Empty);
     bb.RaisePropertyChanged();
     bb.RaisePropertiesChanged(null);
     bb.RaisePropertiesChanged(string.Empty);
 }
        public void RaisePropertyChangedWithNoParametersTest_B251476()
        {
            BindableBaseTest bb = new BindableBaseTest();

            bb.RaisePropertyChanged(null);
            bb.RaisePropertyChanged(string.Empty);
            bb.RaisePropertyChanged();
            bb.RaisePropertiesChanged(null);
            bb.RaisePropertiesChanged(string.Empty);
        }
 public void PropertyChangedCallbackAndPropertyChangedEventOrderTest() {
     BindableBaseTest bb = new BindableBaseTest();
     bool propertyChangedCalled = false;
     bb.PropertyChanged += (s, e) => {
         propertyChangedCalled = true;
         Assert.AreEqual("SomeProperty7", e.PropertyName);
         Assert.AreEqual(0, bb.ChangedCallbackCallCount);
     };
     bb.SomeProperty7 = 777;
     Assert.IsTrue(propertyChangedCalled);
     Assert.AreEqual(1, bb.ChangedCallbackCallCount);
 }
        public void NoNestedReferenceObjects()
        {
            var bindable = new BindableBaseTest()
            {
                SomeProperty2 = 117
            };
            var values = typeof(BindableBase)
                         .GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                         .Select(x => new { x.Name, Value = x.GetValue(bindable) })
                         .ToArray();

            Assert.True(values.All(x => x.Value == null));
        }
 public void OnPropertyChangedTest() {
     BindableBaseTest bb = new BindableBaseTest();
     int count = 0;
     string propName = null;
     bb.SomeProperty = 50;
     bb.PropertyChanged += (o, e) => { count++; propName = e.PropertyName; };
     bb.SomeProperty = 150;
     Assert.AreEqual("SomeProperty", propName);
     Assert.AreEqual(1, count);
     bb.SomeProperty8 = 150;
     Assert.AreEqual("SomeProperty8", propName);
     Assert.AreEqual(2, count);
 }
        public void PropertyChangedCallbackAndPropertyChangedEventOrderTest()
        {
            BindableBaseTest bb = new BindableBaseTest();
            bool             propertyChangedCalled = false;

            bb.PropertyChanged += (s, e) => {
                propertyChangedCalled = true;
                Assert.AreEqual("SomeProperty7", e.PropertyName);
                Assert.AreEqual(0, bb.ChangedCallbackCallCount);
            };
            bb.SomeProperty7 = 777;
            Assert.IsTrue(propertyChangedCalled);
            Assert.AreEqual(1, bb.ChangedCallbackCallCount);
        }
        public void OnPropertyChangedTest()
        {
            BindableBaseTest bb = new BindableBaseTest();
            int    count        = 0;
            string propName     = null;

            bb.SomeProperty     = 50;
            bb.PropertyChanged += (o, e) => { count++; propName = e.PropertyName; };
            bb.SomeProperty     = 150;
            Assert.AreEqual("SomeProperty", propName);
            Assert.AreEqual(1, count);
            bb.SomeProperty8 = 150;
            Assert.AreEqual("SomeProperty8", propName);
            Assert.AreEqual(2, count);
        }
        public void SetPropertyWithLambdaTest()
        {
            BindableBaseTest bb = new BindableBaseTest();
            int    count        = 0;
            string propName     = null;

            bb.SomeProperty3    = 50;
            bb.PropertyChanged += (o, e) => { count++; propName = e.PropertyName; };
            bb.SomeProperty3    = 150;
            Assert.AreEqual("SomeProperty3", propName);
            Assert.AreEqual(1, count);
            Assert.AreEqual(150, bb.SomeProperty3);

            bb.SomeProperty3 = 150;
            Assert.AreEqual(1, count);
        }
        public void SetPropertyWithCallbackTest()
        {
            BindableBaseTest bb = new BindableBaseTest();
            int    count        = 0;
            string propName     = null;

            bb.SomeProperty7 = 50;
            Assert.AreEqual(1, bb.ChangedCallbackCallCount);
            bb.PropertyChanged += (o, e) => { count++; propName = e.PropertyName; };
            bb.SomeProperty7    = 150;

            Assert.AreEqual(2, bb.ChangedCallbackCallCount);
            Assert.AreEqual("SomeProperty7", propName);
            Assert.AreEqual(1, count);
            Assert.AreEqual(150, bb.SomeProperty7);

            bb.SomeProperty7 = 150;
            Assert.AreEqual(1, count);
        }
        public void OnPropertiesChangedTest()
        {
            BindableBaseTest bb     = new BindableBaseTest();
            int           count     = 0;
            List <string> propNames = new List <string>();

            bb.PropertyChanged += (o, e) => { count++; propNames.Add(e.PropertyName); };
            bb.SomeProperty9    = 150;
            Assert.AreEqual("SomeProperty", propNames[0]);
            Assert.AreEqual("SomeProperty9", propNames[1]);
            Assert.AreEqual(2, count);

            propNames.Clear();
            bb.SomeProperty10 = 150;
            Assert.AreEqual("SomeProperty2", propNames[0]);
            Assert.AreEqual("SomeProperty10", propNames[1]);
            Assert.AreEqual(4, count);

            propNames.Clear();
            bb.SomeProperty11 = 150;
            Assert.AreEqual("SomeProperty2", propNames[0]);
            Assert.AreEqual("SomeProperty3", propNames[1]);
            Assert.AreEqual("SomeProperty10", propNames[2]);
            Assert.AreEqual(7, count);

            propNames.Clear();
            bb.SomeProperty12 = 150;
            Assert.AreEqual("SomeProperty2", propNames[0]);
            Assert.AreEqual("SomeProperty3", propNames[1]);
            Assert.AreEqual("SomeProperty10", propNames[2]);
            Assert.AreEqual("SomeProperty11", propNames[3]);
            Assert.AreEqual(11, count);

            propNames.Clear();
            bb.SomeProperty13 = 150;
            Assert.AreEqual("SomeProperty2", propNames[0]);
            Assert.AreEqual("SomeProperty3", propNames[1]);
            Assert.AreEqual("SomeProperty10", propNames[2]);
            Assert.AreEqual("SomeProperty11", propNames[3]);
            Assert.AreEqual("SomeProperty12", propNames[4]);
            Assert.AreEqual(16, count);
        }
        public void OnPropertiesChangedTest() {
            BindableBaseTest bb = new BindableBaseTest();
            int count = 0;
            List<string> propNames = new List<string>();
            bb.PropertyChanged += (o, e) => { count++; propNames.Add(e.PropertyName); };
            bb.SomeProperty9 = 150;
            Assert.AreEqual("SomeProperty", propNames[0]);
            Assert.AreEqual("SomeProperty9", propNames[1]);
            Assert.AreEqual(2, count);

            propNames.Clear();
            bb.SomeProperty10 = 150;
            Assert.AreEqual("SomeProperty2", propNames[0]);
            Assert.AreEqual("SomeProperty10", propNames[1]);
            Assert.AreEqual(4, count);

            propNames.Clear();
            bb.SomeProperty11 = 150;
            Assert.AreEqual("SomeProperty2", propNames[0]);
            Assert.AreEqual("SomeProperty3", propNames[1]);
            Assert.AreEqual("SomeProperty10", propNames[2]);
            Assert.AreEqual(7, count);

            propNames.Clear();
            bb.SomeProperty12 = 150;
            Assert.AreEqual("SomeProperty2", propNames[0]);
            Assert.AreEqual("SomeProperty3", propNames[1]);
            Assert.AreEqual("SomeProperty10", propNames[2]);
            Assert.AreEqual("SomeProperty11", propNames[3]);
            Assert.AreEqual(11, count);

            propNames.Clear();
            bb.SomeProperty13 = 150;
            Assert.AreEqual("SomeProperty2", propNames[0]);
            Assert.AreEqual("SomeProperty3", propNames[1]);
            Assert.AreEqual("SomeProperty10", propNames[2]);
            Assert.AreEqual("SomeProperty11", propNames[3]);
            Assert.AreEqual("SomeProperty12", propNames[4]);
            Assert.AreEqual(16, count);
        }
        public void SetPropertyInvalidLambdaTest3()
        {
            BindableBaseTest bb = new BindableBaseTest();

            bb.SomeProperty6 = 150;
        }
        public void SetPropertyWithLambdaTest() {
            BindableBaseTest bb = new BindableBaseTest();
            int count = 0;
            string propName = null;
            bb.SomeProperty3 = 50;
            bb.PropertyChanged += (o, e) => { count++; propName = e.PropertyName; };
            bb.SomeProperty3 = 150;
            Assert.AreEqual("SomeProperty3", propName);
            Assert.AreEqual(1, count);
            Assert.AreEqual(150, bb.SomeProperty3);

            bb.SomeProperty3 = 150;
            Assert.AreEqual(1, count);
        }
 public void SetPropertyInvalidLambdaTest3() {
     BindableBaseTest bb = new BindableBaseTest();
     bb.SomeProperty6 = 150;
 }
        public void SetPropertyWithCallbackTest() {
            BindableBaseTest bb = new BindableBaseTest();
            int count = 0;
            string propName = null;
            bb.SomeProperty7 = 50;
            Assert.AreEqual(1, bb.ChangedCallbackCallCount);
            bb.PropertyChanged += (o, e) => { count++; propName = e.PropertyName; };
            bb.SomeProperty7 = 150;

            Assert.AreEqual(2, bb.ChangedCallbackCallCount);
            Assert.AreEqual("SomeProperty7", propName);
            Assert.AreEqual(1, count);
            Assert.AreEqual(150, bb.SomeProperty7);

            bb.SomeProperty7 = 150;
            Assert.AreEqual(1, count);
        }