Ejemplo n.º 1
0
        public void ShouldSendMessageWithPropertiesWhenPublishing()
        {
            ITestMessage testMessage = new TestMessage();

            A.CallTo(() => _messagePropertyProvider.GetProperties(testMessage)).Returns(new Dictionary <string, object> {
                { "key1", 1 }, { "key2", "2" }, { "key3", 3.0 }, { "key4", 4L }, { "key5", true }
            });

            _publisher.PublishAsync(testMessage);
            _testScheduler.AdvanceBy(1);

            A.CallTo(() => _producer.Send(_message, MsgDeliveryMode.NonPersistent, MsgPriority.Normal, TimeSpan.Zero)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => _message.Properties.SetInt("key1", 1)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => _message.Properties.SetString("key2", "2")).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => _message.Properties.SetDouble("key3", 3.0)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => _message.Properties.SetLong("key4", 4L)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => _message.Properties.SetBool("key5", true)).MustHaveHappened(Repeated.Exactly.Once);
        }
Ejemplo n.º 2
0
        public Task PublishAsync(TMessage message)
        {
            IEnumerable <KeyValuePair <string, object> > properties = _propertyProvider.GetProperties(message);

            return(PublishAsync(message, properties));
        }