Exemple #1
0
            public void UnregistersRegisteredHandlerWithTag()
            {
                var mediator  = new MessageMediator();
                var recipient = new MessageRecipient();

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

                Assert.IsTrue(mediator.IsRegistered <string>(recipient, recipient.OnMessage, "myTag"));
                Assert.IsTrue(mediator.Unregister <string>(recipient, recipient.OnMessage, "myTag"));
                Assert.IsFalse(mediator.IsRegistered <string>(recipient, recipient.OnMessage, "myTag"));
            }
Exemple #2
0
            public void RegistersHandler()
            {
                var mediator  = new MessageMediator();
                var recipient = new MessageRecipient();

                Assert.IsFalse(mediator.IsRegistered <string>(recipient, recipient.OnMessage));

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

                Assert.IsTrue(mediator.IsRegistered <string>(recipient, recipient.OnMessage));
            }
Exemple #3
0
            public void ReturnsTrueAfterRegistration()
            {
                var recipient       = new MessageRecipient();
                var messageMediator = new MessageMediator();

                messageMediator.Register <string>(recipient, recipient.OnMessage);
                Assert.IsTrue(messageMediator.IsRegistered <string>(recipient, recipient.OnMessage));
            }
Exemple #4
0
            public void ReturnsFalseForUnregisteredHandler()
            {
                var mediator  = new MessageMediator();
                var recipient = new MessageRecipient();

                Assert.IsFalse(mediator.IsRegistered <string>(recipient, recipient.OnMessage));
                Assert.IsFalse(mediator.Unregister <string>(recipient, recipient.OnMessage));
            }
Exemple #5
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));
            }
Exemple #6
0
            public void ReturnsFalseAfterGarbageCollected()
            {
                var recipient       = new MessageRecipient();
                var messageMediator = new MessageMediator();

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

                recipient = null;

                GC.Collect();

                recipient = new MessageRecipient();
                Assert.IsFalse(messageMediator.IsRegistered <string>(recipient, recipient.OnMessage));
            }
Exemple #7
0
            public void UnregistersAllMethodsOfRecipient()
            {
                var mediator  = new MessageMediator();
                var recipient = new MessageRecipient();

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

                Assert.IsTrue(mediator.IsRegistered <string>(recipient, recipient.OnMessage));
                Assert.IsTrue(mediator.IsRegistered <string>(recipient, recipient.AnotherOnMessage));
                Assert.IsTrue(mediator.IsRegistered <string>(recipient, recipient.YetAnotherOnMessage));

                mediator.UnregisterRecipient(recipient);

                Assert.IsFalse(mediator.IsRegistered <string>(recipient, recipient.OnMessage));
                Assert.IsFalse(mediator.IsRegistered <string>(recipient, recipient.AnotherOnMessage));
                Assert.IsFalse(mediator.IsRegistered <string>(recipient, recipient.YetAnotherOnMessage));
            }
            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));
            }
            public void UnregistersAllMethodsOfRecipient()
            {
                var mediator = new MessageMediator();
                var recipient = new MessageRecipient();

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

                Assert.IsTrue(mediator.IsRegistered<string>(recipient, recipient.OnMessage));
                Assert.IsTrue(mediator.IsRegistered<string>(recipient, recipient.AnotherOnMessage));
                Assert.IsTrue(mediator.IsRegistered<string>(recipient, recipient.YetAnotherOnMessage));

                mediator.UnregisterRecipient(recipient);

                Assert.IsFalse(mediator.IsRegistered<string>(recipient, recipient.OnMessage));
                Assert.IsFalse(mediator.IsRegistered<string>(recipient, recipient.AnotherOnMessage));
                Assert.IsFalse(mediator.IsRegistered<string>(recipient, recipient.YetAnotherOnMessage));
            }
            public void ReturnsFalseForUnregisteredHandler()
            {
                var mediator = new MessageMediator();
                var recipient = new MessageRecipient();

                Assert.IsFalse(mediator.IsRegistered<string>(recipient, recipient.OnMessage));
                Assert.IsFalse(mediator.Unregister<string>(recipient, recipient.OnMessage));
            }
            public void UnregistersRegisteredHandlerWithTag()
            {
                var mediator = new MessageMediator();
                var recipient = new MessageRecipient();

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

                Assert.IsTrue(mediator.IsRegistered<string>(recipient, recipient.OnMessage, "myTag"));
                Assert.IsTrue(mediator.Unregister<string>(recipient, recipient.OnMessage, "myTag"));
                Assert.IsFalse(mediator.IsRegistered<string>(recipient, recipient.OnMessage, "myTag"));
            }
            public void RegistersHandler()
            {
                var mediator = new MessageMediator();
                var recipient = new MessageRecipient();

                Assert.IsFalse(mediator.IsRegistered<string>(recipient, recipient.OnMessage));

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

                Assert.IsTrue(mediator.IsRegistered<string>(recipient, recipient.OnMessage));
            }