Example #1
0
        public void Add_ShouldWriteToQueueWithoutChildren()
        {
            var messageQueue = new MessageQueue<TestPayload>(TestQueueName, null, true);

            var payload = new TestPayload
                {
                    Id = Guid.NewGuid(),
                    Text = "Some test text",
                    Time = DateTime.Now.TimeOfDay
                };

            messageQueue.Add(payload);

            var msgQueue = new MSFT.MessageQueue(messageQueue.Path) {Formatter = new MessageFormatter<TestPayload>()};

            var msg = msgQueue.Receive(TimeSpan.FromSeconds(30));
            msg.Body.Should().NotBeNull();
            msg.Body.Should().BeOfType<TestPayload>();

            var actualPayload = (TestPayload) msg.Body;
            actualPayload.Id.Should().Be(payload.Id);
            actualPayload.Text.Should().Be(payload.Text);
            actualPayload.Time.Should().Be(payload.Time);
        }
Example #2
0
        public void Add_ShouldWriteToQueueWithChildren()
        {
            var messageQueue = new MessageQueue<TestPayload>(TestQueueName, null, true);

            var payload = new TestPayload
            {
                Id = Guid.NewGuid(),
                Text = "Some test text",
                Time = DateTime.Now.TimeOfDay,
                Items = new List<ChildItem>
                    {
                        new ChildItem {Id = Guid.NewGuid(), Text = "Some test text again", Value = 12.34m},
                        new ChildItem {Id = Guid.NewGuid(), Text = "Some test text again and again", Value = 56.78m},
                        new ChildItem {Id = Guid.NewGuid(), Text = "Some test text again and again and again", Value = 90.00m},
                    }
            };

            messageQueue.Add(payload);

            var msgQueue = new MSFT.MessageQueue(messageQueue.Path) { Formatter = new MessageFormatter<TestPayload>() };

            var msg = msgQueue.Receive(TimeSpan.FromSeconds(30));
            msg.Body.Should().NotBeNull();
            msg.Body.Should().BeOfType<TestPayload>();

            var actualPayload = (TestPayload)msg.Body;
            actualPayload.Id.Should().Be(payload.Id);
            actualPayload.Text.Should().Be(payload.Text);
            actualPayload.Time.Should().Be(payload.Time);
            
            actualPayload.Items.Should().NotBeNull();
            actualPayload.Items.Should().HaveCount(3);

            actualPayload.Items[0].ShouldBeEquivalentTo(payload.Items[0]);
            actualPayload.Items[1].ShouldBeEquivalentTo(payload.Items[1]);
            actualPayload.Items[2].ShouldBeEquivalentTo(payload.Items[2]);
        }