public void TestUnsubscriber()
        {
            var messageBroker = new MessageBroker();
            var unsubscriber  = new UnsubscriberMock("anotherKey", "unsub", "joe");
            var message       = new MessageMock("anotherKey", "test");

            messageBroker.Start();
            messageBroker.Subscribe(unsubscriber);
            messageBroker.Unsubscribe(unsubscriber);
            messageBroker.Post(message);

            Assert.Equal("false", unsubscriber.Status);
            Assert.Null(unsubscriber._message);
        }
Beispiel #2
0
        public void TestSubscriberAndPost()
        {
            var messageBroker = new MessageBroker();
            var subscriber    = new SubscriberMock("key", "sub", "andy");
            var message       = new MessageMock("key", "source");

            messageBroker.Start();
            messageBroker.Subscribe(subscriber);
            messageBroker.Post(message);

            Assert.Equal("true", subscriber.Status);
            var cooldown = Task.Run(() => Thread.Sleep(3000));

            Assert.Equal("source", subscriber._message);
        }