Beispiel #1
0
        public void Multiple_Listeners_Do_Not_Receive_Incorrect_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(other_listener.messagesRecieved, 0);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public void Single_Listener_Receives_Correct_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 StubMissive());
            }

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