예제 #1
0
        public void when_handler_weak_reference_is_gone_should_no_longer_receive_messages()
        {
            var objectBoss = new ObjectBoss();
            objectBoss.Configure(x => x.Add<ReceiveMessage>().ForMessagging());

            var recieveMessage = objectBoss.GetInstance<ReceiveMessage>();

            Assert.IsTrue(recieveMessage.Count == 1);
            objectBoss.SendMessage(new AddMessage() { HowMuchToAdd = 5 });
            Assert.IsTrue(recieveMessage.Count == 6);
            objectBoss.UnregisterTypeForMessaging(recieveMessage.GetType());

            Assert.IsNotNull(recieveMessage);
            objectBoss.SendMessage(new AddMessage() { HowMuchToAdd = 5 });
            Assert.IsTrue(recieveMessage.Count == 6);
        }