public void TestConstrainingMessageByBaseClass() { Reset(); Messenger.Reset(); Messenger.Default.Register<TestMessageBase>(this, ReceiveTestMessageBase); var testMessage = new TestMessageImpl(this) { Content = TestContent }; Assert.IsFalse(_messageWasReceived); Assert.IsFalse(_messageWasReceivedInTestMessageBase); Assert.IsFalse(_messageWasReceivedInMessageBase); Assert.IsFalse(_messageWasReceivedInITestMessage); Messenger.Default.Send(testMessage); Assert.IsFalse(_messageWasReceived); Assert.IsFalse(_messageWasReceivedInTestMessageBase); Assert.IsFalse(_messageWasReceivedInMessageBase); Assert.IsFalse(_messageWasReceivedInITestMessage); Messenger.Default.Unregister<ITestMessage>(this); Messenger.Default.Register<TestMessageBase>(this, true, ReceiveTestMessageBase); Messenger.Default.Send(testMessage); Assert.IsTrue(_messageWasReceived); Assert.IsTrue(_messageWasReceivedInTestMessageBase); Assert.IsFalse(_messageWasReceivedInMessageBase); Assert.IsFalse(_messageWasReceivedInITestMessage); }
public void TestConstrainingMessageByBaseClassAndReceiveWithInterface() { Reset(); Messenger.Reset(); Messenger.Default.Register <TestMessageBase>(this, ReceiveITestMessage); var testMessage = new TestMessageImpl(this) { Content = TestContent }; Assert.IsFalse(_messageWasReceived); Assert.IsFalse(_messageWasReceivedInTestMessageBase); Assert.IsFalse(_messageWasReceivedInMessageBase); Assert.IsFalse(_messageWasReceivedInITestMessage); Messenger.Default.Send(testMessage); Assert.IsFalse(_messageWasReceived); Assert.IsFalse(_messageWasReceivedInTestMessageBase); Assert.IsFalse(_messageWasReceivedInMessageBase); Assert.IsFalse(_messageWasReceivedInITestMessage); Messenger.Default.Unregister <ITestMessage>(this); Messenger.Default.Register <TestMessageBase>(this, true, ReceiveITestMessage); Messenger.Default.Send(testMessage); Assert.IsTrue(_messageWasReceived); Assert.IsFalse(_messageWasReceivedInTestMessageBase); Assert.IsFalse(_messageWasReceivedInMessageBase); Assert.IsTrue(_messageWasReceivedInITestMessage); }