Наследование: IReceivePropChanged
Пример #1
0
        public void HookupPropChanged()
        {
            var root       = new RootBoxFdo(new AssembledStyles());
            var noteChange = root as IVwNotifyChange;

            // No target...nothing happens
            noteChange.PropChanged(27, 59, 0, 0, 0);

            // One target
            var target1 = new MockReceivePropChanged();
            var key     = new Tuple <int, int>(27, 59);

            root.AddHookupToPropChanged(key, target1);
            noteChange.PropChanged(27, 59, 0, 0, 0);
            Assert.That(target1.PropChangedCalled, Is.True);

            // two targets
            var target2 = new MockReceivePropChanged();

            root.AddHookupToPropChanged(key, target2);
            target1.PropChangedCalled = false;
            noteChange.PropChanged(27, 59, 0, 0, 0);
            Assert.That(target2.PropChangedCalled, Is.True);
            Assert.That(target1.PropChangedCalled, Is.True);
            // three targets
            var target3 = new MockReceivePropChanged();

            root.AddHookupToPropChanged(key, target3);
            target1.PropChangedCalled = false;
            target2.PropChangedCalled = false;
            noteChange.PropChanged(27, 59, 0, 0, 0);
            Assert.That(target3.PropChangedCalled, Is.True);
            Assert.That(target2.PropChangedCalled, Is.True);
            Assert.That(target1.PropChangedCalled, Is.True);
            // remove (in different order)
            root.RemoveHookupFromPropChanged(key, target2);
            target1.PropChangedCalled = false;
            target2.PropChangedCalled = false;
            target3.PropChangedCalled = false;
            noteChange.PropChanged(27, 59, 0, 0, 0);
            Assert.That(target3.PropChangedCalled, Is.True);
            Assert.That(target2.PropChangedCalled, Is.False);
            Assert.That(target1.PropChangedCalled, Is.True);
            // remove another
            root.RemoveHookupFromPropChanged(key, target1);
            target1.PropChangedCalled = false;
            target3.PropChangedCalled = false;
            noteChange.PropChanged(27, 59, 0, 0, 0);
            Assert.That(target3.PropChangedCalled, Is.True);
            Assert.That(target2.PropChangedCalled, Is.False);
            Assert.That(target1.PropChangedCalled, Is.False);
            // remove last
            root.RemoveHookupFromPropChanged(key, target3);
            target3.PropChangedCalled = false;
            noteChange.PropChanged(27, 59, 0, 0, 0);
            Assert.That(target3.PropChangedCalled, Is.False);
            Assert.That(target2.PropChangedCalled, Is.False);
            Assert.That(target1.PropChangedCalled, Is.False);
            // Check we can still add a couple.
            root.AddHookupToPropChanged(key, target2);
            root.AddHookupToPropChanged(key, target3);
            noteChange.PropChanged(27, 59, 0, 0, 0);
            Assert.That(target3.PropChangedCalled, Is.True);
            Assert.That(target2.PropChangedCalled, Is.True);
            Assert.That(target1.PropChangedCalled, Is.False);
        }
Пример #2
0
		public void HookupPropChanged()
		{
			var root = new RootBoxFdo(new AssembledStyles());
			var noteChange = root as IVwNotifyChange;
			// No target...nothing happens
			noteChange.PropChanged(27, 59, 0, 0, 0);

			// One target
			var target1 = new MockReceivePropChanged();
			var key = new Tuple<int, int>(27, 59);
			root.AddHookupToPropChanged(key, target1);
			noteChange.PropChanged(27, 59, 0, 0, 0);
			Assert.That(target1.PropChangedCalled, Is.True);

			// two targets
			var target2 = new MockReceivePropChanged();
			root.AddHookupToPropChanged(key, target2);
			target1.PropChangedCalled = false;
			noteChange.PropChanged(27, 59, 0, 0, 0);
			Assert.That(target2.PropChangedCalled, Is.True);
			Assert.That(target1.PropChangedCalled, Is.True);
			// three targets
			var target3 = new MockReceivePropChanged();
			root.AddHookupToPropChanged(key, target3);
			target1.PropChangedCalled = false;
			target2.PropChangedCalled = false;
			noteChange.PropChanged(27, 59, 0, 0, 0);
			Assert.That(target3.PropChangedCalled, Is.True);
			Assert.That(target2.PropChangedCalled, Is.True);
			Assert.That(target1.PropChangedCalled, Is.True);
			// remove (in different order)
			root.RemoveHookupFromPropChanged(key, target2);
			target1.PropChangedCalled = false;
			target2.PropChangedCalled = false;
			target3.PropChangedCalled = false;
			noteChange.PropChanged(27, 59, 0, 0, 0);
			Assert.That(target3.PropChangedCalled, Is.True);
			Assert.That(target2.PropChangedCalled, Is.False);
			Assert.That(target1.PropChangedCalled, Is.True);
			// remove another
			root.RemoveHookupFromPropChanged(key, target1);
			target1.PropChangedCalled = false;
			target3.PropChangedCalled = false;
			noteChange.PropChanged(27, 59, 0, 0, 0);
			Assert.That(target3.PropChangedCalled, Is.True);
			Assert.That(target2.PropChangedCalled, Is.False);
			Assert.That(target1.PropChangedCalled, Is.False);
			// remove last
			root.RemoveHookupFromPropChanged(key, target3);
			target3.PropChangedCalled = false;
			noteChange.PropChanged(27, 59, 0, 0, 0);
			Assert.That(target3.PropChangedCalled, Is.False);
			Assert.That(target2.PropChangedCalled, Is.False);
			Assert.That(target1.PropChangedCalled, Is.False);
			// Check we can still add a couple.
			root.AddHookupToPropChanged(key, target2);
			root.AddHookupToPropChanged(key, target3);
			noteChange.PropChanged(27, 59, 0, 0, 0);
			Assert.That(target3.PropChangedCalled, Is.True);
			Assert.That(target2.PropChangedCalled, Is.True);
			Assert.That(target1.PropChangedCalled, Is.False);

		}