示例#1
0
        public void NotifierMultiSendMessage()
        {
            var handler = new MyMultipleMessageHandler();

            Simulator.Notifier.Subscribe <MyMessage>(handler);
            Simulator.Notifier.Subscribe <MyMessage2>(handler);
            Simulator.Notifier.Notify(new MyMessage {
                MyProperty = 123
            });
            Simulator.Notifier.Notify(new MyMessage2 {
                MyProperty = 123
            });
            Assert.AreEqual(123, handler.MyMessage.MyProperty);
            Assert.AreEqual(123, handler.MyMessage2.MyProperty);
            Simulator.Notifier.UnsubscribeFromAll(handler);
        }
示例#2
0
        public void NotifierMultiSubscribe()
        {
            var handler = new MyMultipleMessageHandler();

            Simulator.Notifier.Subscribe <MyMessage>(handler);
            Assert.IsTrue(Simulator.Notifier.IsSubscribed <MyMessage>(handler));
            Simulator.Notifier.Unsubscribe <MyMessage>(handler);
            Assert.IsFalse(Simulator.Notifier.IsSubscribed <MyMessage>(handler));

            Simulator.Notifier.Subscribe <MyMessage>(handler);
            Simulator.Notifier.Subscribe <MyMessage2>(handler);
            Assert.IsTrue(Simulator.Notifier.IsSubscribed <MyMessage>(handler));
            Assert.IsTrue(Simulator.Notifier.IsSubscribed <MyMessage2>(handler));
            Simulator.Notifier.UnsubscribeFromAll(handler);
            Assert.IsFalse(Simulator.Notifier.IsSubscribed <MyMessage>(handler));
            Assert.IsFalse(Simulator.Notifier.IsSubscribed <MyMessage2>(handler));
        }