コード例 #1
0
        public void OnlyDequeuesMessageOnce()
        {
            var message1 = new SampleCommand {
                SomeContents = Guid.NewGuid().ToString()
            };
            var message2 = new SampleCommand {
                SomeContents = Guid.NewGuid().ToString()
            };

            _sut.Enqueue(message1);
            _sut.Enqueue(message2);
            using (var trans = new TransactionScope())
            {
                var record = _sut.Dequeue().GetPayload <SampleCommand>();
                Assert.NotNull(record);
                Assert.Equal(message1.SomeContents, record.SomeContents);
                trans.Complete();
            }
            SampleCommand lastMessage;

            using (var trans = new TransactionScope())
            {
                lastMessage = _sut.Dequeue().GetPayload <SampleCommand>();
                trans.Complete();
            }
            Assert.NotNull(lastMessage);
            Assert.Equal(message2.SomeContents, lastMessage.SomeContents);
        }
コード例 #2
0
        public void MessageMarkedAsFailedWillNotBeDequeuedAgain()
        {
            var message1 = new SampleCommand {
                SomeContents = Guid.NewGuid().ToString()
            };
            var message2 = new SampleCommand {
                SomeContents = Guid.NewGuid().ToString()
            };

            _sut.Enqueue(message1);
            _sut.Enqueue(message2);
            using (var trans = new TransactionScope())
            {
                var record = _sut.Dequeue();
                record.MarkAsFailed("The reason for failure");
                trans.Complete();
            }
            SampleCommand lastMessage;

            using (var trans = new TransactionScope())
            {
                lastMessage = _sut.Dequeue().GetPayload <SampleCommand>();
                trans.Complete();
            }
            Assert.NotNull(lastMessage);
            Assert.Equal(message2.SomeContents, lastMessage.SomeContents);
        }
コード例 #3
0
ファイル: QueueFixture.cs プロジェクト: RhysC/SqlQueue
 public void CanEnqueueAndDequeueMessage()
 {
     var message = new SampleCommand { SomeContents = Guid.NewGuid().ToString() };
     _sut.Enqueue(message);
     var record = _sut.Dequeue().GetPayload<SampleCommand>();
     Assert.NotNull(record);
     Assert.Equal(message.SomeContents, record.SomeContents);
 }
コード例 #4
0
ファイル: QueueFixture.cs プロジェクト: RhysC/SqlQueue
 public void DequeuesFirstMessage()
 {
     var message1 = new SampleCommand { SomeContents = Guid.NewGuid().ToString() };
     var message2 = new SampleCommand { SomeContents = Guid.NewGuid().ToString() };
     _sut.Enqueue(message1);
     _sut.Enqueue(message2);
     var record = _sut.Dequeue();
     Assert.NotNull(record);
     Assert.Equal(message1.SomeContents, record.GetPayload<SampleCommand>().SomeContents);
 }
コード例 #5
0
        public void CanEnqueueAndDequeueMessage()
        {
            var message = new SampleCommand {
                SomeContents = Guid.NewGuid().ToString()
            };

            _sut.Enqueue(message);
            var record = _sut.Dequeue().GetPayload <SampleCommand>();

            Assert.NotNull(record);
            Assert.Equal(message.SomeContents, record.SomeContents);
        }
コード例 #6
0
        public void DequeuesFirstMessage()
        {
            var message1 = new SampleCommand {
                SomeContents = Guid.NewGuid().ToString()
            };
            var message2 = new SampleCommand {
                SomeContents = Guid.NewGuid().ToString()
            };

            _sut.Enqueue(message1);
            _sut.Enqueue(message2);
            var record = _sut.Dequeue();

            Assert.NotNull(record);
            Assert.Equal(message1.SomeContents, record.GetPayload <SampleCommand>().SomeContents);
        }
コード例 #7
0
ファイル: QueueFixture.cs プロジェクト: RhysC/SqlQueue
        public void MessageMarkedAsFailedWillBeInTheFailedMessageRepository()
        {
            var message1 = new SampleCommand { SomeContents = Guid.NewGuid().ToString() };
            _sut.Enqueue(message1);
            const string theReasonForFailure = "The reason for failure";
            using (var trans = new TransactionScope())
            {
                var record = _sut.Dequeue();
                _sut.MarkAsFailed(record, theReasonForFailure);
                trans.Complete();
            }

            var failedMessage = _sut.GetFailedMessages().First();

            Assert.NotNull(failedMessage);
            Assert.Equal(message1, failedMessage.GetPayload());
            Assert.Equal(theReasonForFailure, failedMessage.FailureMessage);
        }
コード例 #8
0
        public void MessageMarkedAsFailedWillBeInTheFailedMessageRepository()
        {
            var message1 = new SampleCommand {
                SomeContents = Guid.NewGuid().ToString()
            };

            _sut.Enqueue(message1);
            const string theReasonForFailure = "The reason for failure";

            using (var trans = new TransactionScope())
            {
                var record = _sut.Dequeue();
                _sut.MarkAsFailed(record, theReasonForFailure);
                trans.Complete();
            }

            var failedMessage = _sut.GetFailedMessages().First();

            Assert.NotNull(failedMessage);
            Assert.Equal(message1, failedMessage.GetPayload());
            Assert.Equal(theReasonForFailure, failedMessage.FailureMessage);
        }
コード例 #9
0
        public void MessageNotMarkedAsFailedWillNotBeInTheFailedMessageRepository()
        {
            var message1 = new SampleCommand {
                SomeContents = Guid.NewGuid().ToString()
            };
            var message2 = new SampleCommand {
                SomeContents = Guid.NewGuid().ToString()
            };
            var message3 = new SampleCommand {
                SomeContents = Guid.NewGuid().ToString()
            };

            _sut.Enqueue(message1);
            _sut.Enqueue(message2);
            _sut.Enqueue(message3);
            using (var trans = new TransactionScope())
            {
                _sut.Dequeue();
                trans.Complete();
            }
            using (var trans = new TransactionScope())
            {
                _sut.MarkAsFailed(_sut.Dequeue(), "Oh, my failures...");
                trans.Complete();
            }
            using (var trans = new TransactionScope())
            {
                _sut.Dequeue();
                trans.Complete();
            }
            var failedMessages = _sut.GetFailedMessages().Select(m => m.GetPayload()).ToArray();

            Assert.DoesNotContain(message1, failedMessages);
            Assert.Contains(message2, failedMessages);
            Assert.DoesNotContain(message3, failedMessages);
        }
コード例 #10
0
ファイル: QueueFixture.cs プロジェクト: RhysC/SqlQueue
 public void MessageMarkedAsFailedWillNotBeDequeuedAgain()
 {
     var message1 = new SampleCommand { SomeContents = Guid.NewGuid().ToString() };
     var message2 = new SampleCommand { SomeContents = Guid.NewGuid().ToString() };
     _sut.Enqueue(message1);
     _sut.Enqueue(message2);
     using (var trans = new TransactionScope())
     {
         var record = _sut.Dequeue();
         record.MarkAsFailed("The reason for failure");
         trans.Complete();
     }
     SampleCommand lastMessage;
     using (var trans = new TransactionScope())
     {
         lastMessage = _sut.Dequeue().GetPayload<SampleCommand>();
         trans.Complete();
     }
     Assert.NotNull(lastMessage);
     Assert.Equal(message2.SomeContents, lastMessage.SomeContents);
 }
コード例 #11
0
ファイル: QueueFixture.cs プロジェクト: RhysC/SqlQueue
 public void OnlyDequeuesMessageOnce()
 {
     var message1 = new SampleCommand { SomeContents = Guid.NewGuid().ToString() };
     var message2 = new SampleCommand { SomeContents = Guid.NewGuid().ToString() };
     _sut.Enqueue(message1);
     _sut.Enqueue(message2);
     using (var trans = new TransactionScope())
     {
         var record = _sut.Dequeue().GetPayload<SampleCommand>();
         Assert.NotNull(record);
         Assert.Equal(message1.SomeContents, record.SomeContents);
         trans.Complete();
     }
     SampleCommand lastMessage;
     using (var trans = new TransactionScope())
     {
         lastMessage = _sut.Dequeue().GetPayload<SampleCommand>();
         trans.Complete();
     }
     Assert.NotNull(lastMessage);
     Assert.Equal(message2.SomeContents, lastMessage.SomeContents);
 }
コード例 #12
0
ファイル: QueueFixture.cs プロジェクト: RhysC/SqlQueue
 public void MessageNotMarkedAsFailedWillNotBeInTheFailedMessageRepository()
 {
     var message1 = new SampleCommand { SomeContents = Guid.NewGuid().ToString() };
     var message2 = new SampleCommand { SomeContents = Guid.NewGuid().ToString() };
     var message3 = new SampleCommand { SomeContents = Guid.NewGuid().ToString() };
     _sut.Enqueue(message1);
     _sut.Enqueue(message2);
     _sut.Enqueue(message3);
     using (var trans = new TransactionScope())
     {
         _sut.Dequeue();
         trans.Complete();
     }
     using (var trans = new TransactionScope())
     {
         _sut.MarkAsFailed( _sut.Dequeue(), "Oh, my failures...");
         trans.Complete();
     }
     using (var trans = new TransactionScope())
     {
         _sut.Dequeue();
         trans.Complete();
     }
     var failedMessages = _sut.GetFailedMessages().Select(m=>m.GetPayload()).ToArray();
     Assert.DoesNotContain(message1, failedMessages);
     Assert.Contains(message2, failedMessages);
     Assert.DoesNotContain(message3, failedMessages);
 }