public void MessageQueue_Add_MessageCounterSignal_IsSet_true()
        {
            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();
            messageQueue.Add(testMessageFrame);

            Assert.IsTrue(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #2
0
        public void MessageQueue_Add_MessageCounterSignal_IsSet_true()
        {
            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();

            messageQueue.Add(testMessageFrame);

            Assert.IsTrue(messageQueue.MessageCounterSignal.IsSet);
        }
        public void MessageQueue_AddRange_fires_MessageFrameAdded()
        {
            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();
            MessageFrame messageFrame = null;
            messageQueue.MessageFrameAdded += m => { messageFrame = m; };

            messageQueue.AddRange(new [] { testMessageFrame });

            Assert.AreSame(testMessageFrame, messageFrame);
        }
Пример #4
0
        public void MessageQueue_AddRange_fires_MessageFrameAdded()
        {
            var testMessageFrame = new MessageFrame();

            var          messageQueue = new MessageQueueSingle();
            MessageFrame messageFrame = null;

            messageQueue.MessageFrameAdded += m => { messageFrame = m; };

            messageQueue.AddRange(new [] { testMessageFrame });

            Assert.AreSame(testMessageFrame, messageFrame);
        }
        public void MessageQueue_Add_single_message_SendFromQueue_message_writer_receives_message()
        {
            var messageFramesWritten = new List<MessageFrame>();
            var messageFramesWriter = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();
            messageQueue.Add(testMessageFrame);

            messageQueue.SendFromQueue(messageFramesWriter);

            Assert.AreSame(testMessageFrame, messageFramesWritten.First());
        }
Пример #6
0
        public void MessageQueue_Add_single_message_SendFromQueueAsync_fails_MessageCounterSignal_IsSet_true()
        {
            var errorMessageFrameWriter = CreateMessageFrameWriterThrowsIOException();

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();

            messageQueue.Add(testMessageFrame);

            Assert.Throws <AggregateException>(() => messageQueue.SendFromQueueAsync(errorMessageFrameWriter, CancellationToken.None).Wait());

            Assert.IsTrue(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #7
0
        public void MessageQueue_Add_single_message_SendFromQueue_fails_MessageCounterSignal_IsSet_true()
        {
            var errorMessageFrameWriter = CreateMessageFrameWriterThrowsIOException();

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();

            messageQueue.Add(testMessageFrame);

            Assert.Throws <IOException>(() => messageQueue.SendFromQueue(errorMessageFrameWriter));

            Assert.IsTrue(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #8
0
        public void MessageQueue_Add_single_message_SendFromQueue_MessageCounterSignal_IsSet_false()
        {
            var messageFramesWritten = new List <MessageFrame>();
            var messageFramesWriter  = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();

            messageQueue.Add(testMessageFrame);

            messageQueue.SendFromQueue(messageFramesWriter);

            Assert.IsFalse(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #9
0
        public void MessageQueue_Add_single_message_SendFromQueue_message_writer_receives_message()
        {
            var messageFramesWritten = new List <MessageFrame>();
            var messageFramesWriter  = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();

            messageQueue.Add(testMessageFrame);

            messageQueue.SendFromQueue(messageFramesWriter);

            Assert.AreSame(testMessageFrame, messageFramesWritten.First());
        }
Пример #10
0
        public void MessageQueue_AddRange_two_messages_after_SendFromQueueAsync_MessageCounterSignal_IsSet_true()
        {
            var messageFramesWritten = new List <MessageFrame>();
            var messageFramesWriter  = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();

            messageQueue.AddRange(new[] { testMessageFrame, testMessageFrame });

            messageQueue.SendFromQueueAsync(messageFramesWriter, CancellationToken.None).Wait();

            Assert.IsTrue(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #11
0
        public void MessageQueue_Add_single_message_SendFromQueueAsync_MessageCounterSignal_IsSet_false()
        {
            var messageFramesWritten = new List <MessageFrame>();
            var messageFramesWriter  = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();

            messageQueue.Add(testMessageFrame);

            messageQueue.SendFromQueueAsync(messageFramesWriter, CancellationToken.None).Wait();

            Assert.IsFalse(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #12
0
        public void MessageQueue_AddRange_two_messages_SendFromQueueAsync_writer_receive_first_message()
        {
            var messageFramesWritten = new List <MessageFrame>();
            var messageFramesWriter  = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame1 = new MessageFrame();
            var testMessageFrame2 = new MessageFrame();

            var messageQueue = new MessageQueueSingle();

            messageQueue.AddRange(new[] { testMessageFrame1, testMessageFrame2 });

            messageQueue.SendFromQueueAsync(messageFramesWriter, CancellationToken.None).Wait();

            Assert.AreSame(testMessageFrame1, messageFramesWritten.Single());
        }
Пример #13
0
        public void MessageQueue_AddRange_two_messages_after_SendFromQueue_twice_MessageCounterSignal_IsSet_false()
        {
            var messageFramesWritten = new List <MessageFrame>();
            var messageFramesWriter  = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();

            messageQueue.AddRange(new[] { testMessageFrame, testMessageFrame });

            messageQueue.SendFromQueue(messageFramesWriter);
            messageQueue.SendFromQueue(messageFramesWriter);

            Assert.IsFalse(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #14
0
        public void MessageQueue_Add_single_message_SendFromQueue_fails_once_then_succeeds_MessageCounterSignal_IsSet_false()
        {
            var errorMessageFrameWriter = CreateMessageFrameWriterThrowsIOException();
            var messageFramesWritten    = new List <MessageFrame>();
            var messageFramesWriter     = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();

            messageQueue.Add(testMessageFrame);

            Assert.Throws <IOException>(() => messageQueue.SendFromQueue(errorMessageFrameWriter));
            messageQueue.SendFromQueue(messageFramesWriter);

            Assert.IsFalse(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #15
0
        public void MessageQueue_AddRange_two_messages_SendFromQueue_twice_writer_receives_both_messages()
        {
            var messageFramesWritten = new List <MessageFrame>();
            var messageFramesWriter  = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame1 = new MessageFrame();
            var testMessageFrame2 = new MessageFrame();

            var messageQueue = new MessageQueueSingle();

            messageQueue.AddRange(new[] { testMessageFrame1, testMessageFrame2 });

            messageQueue.SendFromQueue(messageFramesWriter);
            messageQueue.SendFromQueue(messageFramesWriter);

            Assert.AreSame(testMessageFrame1, messageFramesWritten.First());
            Assert.AreSame(testMessageFrame2, messageFramesWritten.Skip(1).Single());
        }
Пример #16
0
        public void MessageQueue_AddRange_two_messages_after_SendFromQueue_MessageCounterSignal_IsSet_true()
        {
            var messageFramesWritten = new List<MessageFrame>();
            var messageFramesWriter = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();
            messageQueue.AddRange(new[] { testMessageFrame, testMessageFrame });

            messageQueue.SendFromQueue(messageFramesWriter);

            Assert.IsTrue(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #17
0
        public void MessageQueue_Add_single_message_SendFromQueueAsync_MessageCounterSignal_IsSet_false()
        {
            var messageFramesWritten = new List<MessageFrame>();
            var messageFramesWriter = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();
            messageQueue.Add(testMessageFrame);

            messageQueue.SendFromQueueAsync(messageFramesWriter, CancellationToken.None).Wait();

            Assert.IsFalse(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #18
0
        public void MessageQueue_empty_MessageCounterSignal_IsSet_false()
        {
            var messageQueue = new MessageQueueSingle();

            Assert.IsFalse(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #19
0
        public void MessageQueue_Add_single_message_SendFromQueueAsync_fails_once_then_succeeds_MessageCounterSignal_IsSet_false()
        {
            var errorMessageFrameWriter = CreateMessageFrameWriterThrowsIOException();
            var messageFramesWritten = new List<MessageFrame>();
            var messageFramesWriter = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();
            messageQueue.Add(testMessageFrame);

            Assert.Throws<AggregateException>(() => messageQueue.SendFromQueueAsync(errorMessageFrameWriter, CancellationToken.None).Wait());
            messageQueue.SendFromQueueAsync(messageFramesWriter, CancellationToken.None).Wait();

            Assert.IsFalse(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #20
0
 public void MessageQueue_empty_MessageCounterSignal_IsSet_false()
 {
     var messageQueue = new MessageQueueSingle();
     Assert.IsFalse(messageQueue.MessageCounterSignal.IsSet);
 }
Пример #21
0
        public void MessageQueue_AddRange_two_messages_SendFromQueue_writer_receive_first_message()
        {
            var messageFramesWritten = new List<MessageFrame>();
            var messageFramesWriter = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame1 = new MessageFrame();
            var testMessageFrame2 = new MessageFrame();

            var messageQueue = new MessageQueueSingle();
            messageQueue.AddRange(new[] { testMessageFrame1, testMessageFrame2 });

            messageQueue.SendFromQueue(messageFramesWriter);

            Assert.AreSame(testMessageFrame1, messageFramesWritten.Single());
        }
Пример #22
0
        public void MessageQueue_Add_single_message_SendFromQueue_MessageCounterSignal_IsSet_false()
        {
            var messageFramesWritten = new List<MessageFrame>();
            var messageFramesWriter = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();
            messageQueue.Add(testMessageFrame);

            messageQueue.SendFromQueue(messageFramesWriter);

            Assert.IsFalse(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #23
0
        public void MessageQueue_AddRange_two_messages_SendFromQueueAsync_twice_writer_receives_both_messages()
        {
            var messageFramesWritten = new List<MessageFrame>();
            var messageFramesWriter = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame1 = new MessageFrame();
            var testMessageFrame2 = new MessageFrame();

            var messageQueue = new MessageQueueSingle();
            messageQueue.AddRange(new[] { testMessageFrame1, testMessageFrame2 });

            messageQueue.SendFromQueueAsync(messageFramesWriter, CancellationToken.None).Wait();
            messageQueue.SendFromQueueAsync(messageFramesWriter, CancellationToken.None).Wait();

            Assert.AreSame(testMessageFrame1, messageFramesWritten.First());
            Assert.AreSame(testMessageFrame2, messageFramesWritten.Skip(1).Single());
        }
Пример #24
0
        public void MessageQueue_Add_single_message_SendFromQueue_fails_MessageCounterSignal_IsSet_true()
        {
            var errorMessageFrameWriter = CreateMessageFrameWriterThrowsIOException();

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();
            messageQueue.Add(testMessageFrame);

            Assert.Throws<IOException>(() => messageQueue.SendFromQueue(errorMessageFrameWriter));

            Assert.IsTrue(messageQueue.MessageCounterSignal.IsSet);
        }
Пример #25
0
        public void MessageQueue_AddRange_two_messages_after_SendFromQueueAsync_twice_MessageCounterSignal_IsSet_false()
        {
            var messageFramesWritten = new List<MessageFrame>();
            var messageFramesWriter = CreateMessageFrameWriter(messageFramesWritten);

            var testMessageFrame = new MessageFrame();

            var messageQueue = new MessageQueueSingle();
            messageQueue.AddRange(new[] { testMessageFrame, testMessageFrame });

            messageQueue.SendFromQueueAsync(messageFramesWriter, CancellationToken.None).Wait();
            messageQueue.SendFromQueueAsync(messageFramesWriter, CancellationToken.None).Wait();

            Assert.IsFalse(messageQueue.MessageCounterSignal.IsSet);
        }