示例#1
0
        public void TestSubscribePropChangedTyped()
        {
            // TODO: AAA
            mod1 = new AllPropsRegisteredModel(PropBagTypeSafetyMode.AllPropsMustBeRegistered,
                                               _amHelpers.StoreAccessCreator, _amHelpers.PropFactory_V1);

            mod1.SubscribeToPropChanged <int>(DoWhenPropIntChangesTyped, "PropInt");

            mod1.PropInt = 0;
            mod1.PropInt = 1;

            Assert.That(typedOldVal, Is.EqualTo(0), "The old value should have been 0.");
            Assert.That(typedNewVal, Is.EqualTo(1), "The new value should have been 1.");

            mod1.UnSubscribeToPropChanged <int>(DoWhenPropIntChangesTyped, "PropInt");
            mod1.PropInt = 2;

            Assert.That(typedOldVal, Is.EqualTo(0), "The old value should have been 0. The action did not get unsubscribed.");
            Assert.That(typedNewVal, Is.EqualTo(1), "The new value should have been 1.");
        }
示例#2
0
        public void TestSubscribePropChangedGen()
        {
            // TODO: AAA
            mod1 = new AllPropsRegisteredModel(PropBagTypeSafetyMode.AllPropsMustBeRegistered,
                                               _amHelpers.StoreAccessCreator, _amHelpers.PropFactory_V1);

            mod1.SubscribeToPropChanged(eventHandler: DoWhenPropIntChangesGen, propertyName: "PropInt", propertyType: typeof(int));

            mod1.PropInt = 0;
            mod1.PropInt = 1;

            Assert.That(genObjOldVal, Is.EqualTo(0), "The old value should have been 0.");
            Assert.That(genObjNewVal, Is.EqualTo(1), "The new value should have been 1.");

            mod1.UnSubscribeToPropChanged(eventHandler: DoWhenPropIntChangesGen, propertyName: "PropInt", propertyType: typeof(int));
            mod1.PropInt = 2;

            Assert.That(genObjOldVal, Is.EqualTo(0), "The old value should have been 0. The action did not get unsubcribed.");
            Assert.That(genObjNewVal, Is.EqualTo(1), "The new value should have been 1.");
        }