Example #1
0
        public void Listener_Can_Unsubscribe()
        {
            var listener   = new StubListener();
            var aggregator = new MissiveAggregator();

            aggregator.Register(listener);
            aggregator.Publish(new StubMissive());
            Assert.AreEqual(listener.messagesRecieved, 1);

            aggregator.Unregister(listener);
            aggregator.Publish(new StubMissive());
            Assert.AreEqual(listener.messagesRecieved, 1);
        }
Example #2
0
        public void Single_Listener_Does_Not_Receive_Incorrect_Messages(int sent_messages)
        {
            var listener   = new StubListener();
            var aggregator = new MissiveAggregator();

            aggregator.Register(listener);

            for (var i = 0; i < sent_messages; i++)
            {
                aggregator.Publish(new OtherStubMissive());
            }

            Assert.AreEqual(listener.messagesRecieved, 0);
        }
Example #3
0
        public void Multiple_Listeners_Receive_Correct_Messages(int sent_messages)
        {
            var listener       = new StubListener();
            var other_listener = new OtherStubListener();
            var aggregator     = new MissiveAggregator();

            aggregator.Register(listener);
            aggregator.Register(other_listener);

            for (var i = 0; i < sent_messages; i++)
            {
                aggregator.Publish(new StubMissive());
            }

            Assert.AreEqual(listener.messagesRecieved, sent_messages);
        }