Beispiel #1
0
        public void Notifier_VirtualProperty()
        {
            var mock = new DerivedNotifierMock();

            //(mock as NotifierMock).Integer_Virtual_AutoImplemented_WithoutDefault_RaiseOnChange_NotLocked = 123;
            mock.Integer_Virtual_AutoImplemented_WithoutDefault_RaiseOnChange_NotLocked = 123;

            Assert.Equal(123, mock.Integer_Virtual_AutoImplemented_WithoutDefault_RaiseOnChange_NotLocked);
        }
Beispiel #2
0
        public void Notifier_Binding_OneWay_WithTransformation()
        {
            var source = new DerivedNotifierMock();
            var target = new DerivedNotifierMock();

            source.Integer_AutoImplemented_WithDefault_RaiseOnChange_NotLocked = 111;
            source.Binding(() => source.Integer_AutoImplemented_WithDefault_RaiseOnChange_NotLocked).OneWayTo(target, () => target.String_AutoImplemented_WithDefault_RaiseOnChange_NotLocked, i => i.ToString());
            // Check that the target property will set with source property value
            Assert.Equal(111.ToString(), target.String_AutoImplemented_WithDefault_RaiseOnChange_NotLocked);
            source.Integer_AutoImplemented_WithDefault_RaiseOnChange_NotLocked = 123;
            Assert.Equal(123.ToString(), target.String_AutoImplemented_WithDefault_RaiseOnChange_NotLocked);
        }
Beispiel #3
0
        public void Notifier_Binding_TwoWay()
        {
            var source = new DerivedNotifierMock();
            var target = new DerivedNotifierMock();

            source.Integer_AutoImplemented_WithDefault_RaiseOnChange_NotLocked = 111;
            source.Binding(() => source.Integer_AutoImplemented_WithDefault_RaiseOnChange_NotLocked)
            .TwoWayTo(target, () => target.Integer_AutoImplemented_WithDefault_RaiseOnChange_NotLocked);
            // Check that the target property will set with source property value
            Assert.Equal(111, target.Integer_AutoImplemented_WithDefault_RaiseOnChange_NotLocked);

            source.Integer_AutoImplemented_WithDefault_RaiseOnChange_NotLocked = 123;
            // Check that the bind works in source=>target direction
            Assert.Equal(123, target.Integer_AutoImplemented_WithDefault_RaiseOnChange_NotLocked);

            target.Integer_AutoImplemented_WithDefault_RaiseOnChange_NotLocked = 321;
            // Check that the bind works in target=>source direction
            Assert.Equal(321, source.Integer_AutoImplemented_WithDefault_RaiseOnChange_NotLocked);
        }
Beispiel #4
0
 //[TestInitialize]
 public void TestInitialize()
 {
     //Eliminar todos los contadores
     counters.Clear();
     //Crear todos los contadores
     foreach (var pro in typeof(NotifierMock).GetProperties())
     {
         counters.Add(pro.Name + "_" + PROPERTY_CHANGED, 0);
         counters.Add(pro.Name + "_" + PROPERTY_CHANGED_BASE, 0);
         //counters.Add(pro.Name + "_" + PROPERTY_CHANGING, 0);
         //counters.Add(pro.Name + "_" + PROPERTY_CHANGING_BASE, 0);
         //counters.Add(pro.Name + "_" + PROPERTY_READ, 0);
     }
     //Crear el notificador
     mock = new DerivedNotifierMock();
     //Registrar los eventos del notificador para incrementar los contadores
     //mock.PropertyChanging += (n, e) => IncrementCounter(e.PropertyName, PROPERTY_CHANGING);
     //(mock as INotifyPropertyChanging).PropertyChanging += (s, e) => IncrementCounter(e.PropertyName, PROPERTY_CHANGING_BASE);
     mock.PropertyChanged += (n, e) => IncrementCounter(e.PropertyName, PROPERTY_CHANGED);
     (mock as INotifyPropertyChanged).PropertyChanged += (s, e) => IncrementCounter(e.PropertyName, PROPERTY_CHANGED_BASE);
     //mock.PropertyRead += (n, e) => IncrementCounter(e.PropertyName, PROPERTY_READ);
 }
Beispiel #5
0
        public void ProtectedPropertyTest()
        {
            var o = new DerivedNotifierMock();

            o.ChangeProtected(1);
        }