コード例 #1
0
            public void CleanUpKeepsNonGarbageCollectedHandlersRegistered()
            {
                var mediator  = new MessageMediator();
                var recipient = new MessageRecipient();

                mediator.Register <string>(recipient, recipient.OnMessage);

                mediator.CleanUp();

                Assert.IsTrue(mediator.IsRegistered <string>(recipient, recipient.OnMessage));
            }
コード例 #2
0
            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);
            }
コード例 #3
0
            public void CleanUpWorksWhenNoHandlersRegistered()
            {
                var mediator = new MessageMediator();

                mediator.CleanUp();
            }
コード例 #4
0
            public void CleanUpKeepsNonGarbageCollectedHandlersRegistered()
            {
                var mediator = new MessageMediator();
                var recipient = new MessageRecipient();

                mediator.Register<string>(recipient, recipient.OnMessage);

                mediator.CleanUp();

                Assert.IsTrue(mediator.IsRegistered<string>(recipient, recipient.OnMessage));
            }
コード例 #5
0
            public void CleanUpWorksWhenNoHandlersRegistered()
            {
                var mediator = new MessageMediator();

                mediator.CleanUp();
            }
コード例 #6
0
            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);
            }