public void CleanUpClearsGarbageCollectedHandlers() { var mediator = new MessageMediator(); var recipient = new MessageRecipient(); mediator.Register <string>(recipient, recipient.OnMessage); recipient = null; GC.Collect(); mediator.CleanUp(); Assert.AreEqual(0, mediator.GetRegisteredHandlers <string>().Count); }
public void ReturnsFalseForHandlersClearedByGarbageCollector() { var mediator = new MessageMediator(); var sender = new MessageSender(); var recipient = new MessageRecipient(); mediator.Register <string>(recipient, recipient.OnMessage); recipient = null; GC.Collect(); Assert.IsFalse(sender.SendMessage(mediator, "test")); Assert.AreEqual(0, mediator.GetRegisteredHandlers <string>().Count, "SendMessage should auto cleanup"); }
public void ReturnsFalseForHandlersClearedByGarbageCollector() { var mediator = new MessageMediator(); var sender = new MessageSender(); var recipient = new MessageRecipient(); mediator.Register<string>(recipient, recipient.OnMessage); recipient = null; GC.Collect(); Assert.IsFalse(sender.SendMessage(mediator, "test")); Assert.AreEqual(0, mediator.GetRegisteredHandlers<string>().Count, "SendMessage should auto cleanup"); }
public void CleanUpClearsGarbageCollectedHandlers() { var mediator = new MessageMediator(); var recipient = new MessageRecipient(); mediator.Register<string>(recipient, recipient.OnMessage); recipient = null; GC.Collect(); mediator.CleanUp(); Assert.AreEqual(0, mediator.GetRegisteredHandlers<string>().Count); }