public void SkipSender() { var receiver2 = new ReceiverReturningTrue(); m_dispatcher.AddReceiver(receiver2); Assert.IsNull(receiver2.Args); Assert.IsNull(receiver2.Sender); Assert.IsNull(m_receiver.Args); Assert.IsNull(m_receiver.Sender); // Call without the skip flag, since the default behavior is to skip. m_dispatcher.SendMessage("ProtectedMsgHandled", m_receiver, "Eeee!"); Assert.IsNull(m_receiver.Args); Assert.IsNull(m_receiver.Sender); Assert.AreEqual("Eeee!", receiver2.Args); Assert.AreEqual(m_receiver, receiver2.Sender); receiver2.Args = null; receiver2.Sender = null; // Call with the skip flag. m_dispatcher.SendMessage("ProtectedMsgHandled", m_receiver, "Eeee!", true); Assert.IsNull(m_receiver.Args); Assert.IsNull(m_receiver.Sender); Assert.AreEqual("Eeee!", receiver2.Args); Assert.AreEqual(m_receiver, receiver2.Sender); }
public void IncludeSender() { var receiver2 = new ReceiverReturningTrue(); m_dispatcher.AddReceiver(receiver2); Assert.IsNull(receiver2.Args); Assert.IsNull(receiver2.Sender); Assert.IsNull(m_receiver.Args); Assert.IsNull(m_receiver.Sender); // Call without the skip flag, expecting that default behavior is to skip. m_dispatcher.SendMessage("ProtectedMsgHandled", m_receiver, "Eeee!"); Assert.IsNull(m_receiver.Args); Assert.IsNull(m_receiver.Sender); Assert.AreEqual("Eeee!", receiver2.Args); Assert.AreEqual(m_receiver, receiver2.Sender); receiver2.Args = null; receiver2.Sender = null; // Now call with the skip flag set to false. m_dispatcher.SendMessage("ProtectedMsgHandled", m_receiver, "Eeee!", false); Assert.AreEqual("Eeee!", m_receiver.Args); Assert.AreEqual(m_receiver, m_receiver.Sender); Assert.AreEqual("Eeee!", receiver2.Args); Assert.AreEqual(m_receiver, receiver2.Sender); }
public void DispatchingInterupted() { var firstReceiver = new ReceiverReturningTrue(); m_dispatcher.RemoveReceiver(m_receiver); m_dispatcher.AddReceiver(firstReceiver); m_dispatcher.AddReceiver(m_receiver); Assert.IsNull(firstReceiver.Args); Assert.IsNull(firstReceiver.Sender); Assert.IsNull(m_receiver.Args); Assert.IsNull(m_receiver.Sender); m_dispatcher.SendMessage("ProtectedMsgHandled", this, "Aaaaahhhh!"); Assert.IsNull(m_receiver.Args); Assert.IsNull(m_receiver.Sender); Assert.AreEqual("Aaaaahhhh!", firstReceiver.Args); Assert.AreEqual(this, firstReceiver.Sender); }