示例#1
0
        public void Publish_CustomProxyWithFilter_UsesCorrectProxy()
        {
            var messenger = UtilityMethods.GetMessenger();
            var proxy = new TestProxy();
            messenger.Subscribe<TestMessage>(new Action<TestMessage>(UtilityMethods.FakeDeliveryAction<TestMessage>), new Func<TestMessage, bool>(UtilityMethods.FakeMessageFilter<TestMessage>), proxy);
            var message = new TestMessage(this);

            messenger.Publish<TestMessage>(message);

            Assert.ReferenceEquals(message, proxy.Message);
        }
示例#2
0
        public void Publish_SubscribedMessageNoFilter_GetsActualMessage()
        {
            var messenger = UtilityMethods.GetMessenger();
            ITinyMessage receivedMessage = null;
            var payload = new TestMessage(this);
            messenger.Subscribe<TestMessage>((m) => { receivedMessage = m; });

            messenger.Publish<TestMessage>(payload);

            Assert.ReferenceEquals(payload, receivedMessage);
        }
示例#3
0
        public void Publish_CustomProxyNoFilterStrongReference_UsesCorrectProxy()
        {
            var messenger = UtilityMethods.GetMessenger();
            var proxy = new TestProxy();
            messenger.Subscribe<TestMessage>(new Action<TestMessage>(UtilityMethods.FakeDeliveryAction<TestMessage>), true, proxy);
            var message = new TestMessage(this);

            messenger.Publish<TestMessage>(message);

            Assert.AreSame(message, proxy.Message);
        }