Provides a AK.F1.Timing.IMessageReader decorator which records the AK.F1.Timing.Messages read from an inner AK.F1.Timing.IMessageReader.
Inheritance: MessageReaderBase
コード例 #1
0
 /// <inheritdoc/>        
 protected override void ExecuteCore()
 {
     var path = Path.GetTempFileName();
     using(var reader = new RecordingMessageReader(CreateReader(), path))
     {
         while(reader.Read() != null) { }
     }
     MoveToTmsDirectory(path);
 }
コード例 #2
0
 public void can_record_an_empty_inner_reader()
 {
     using(var output = new MemoryStream())
     {
         using(var reader = new RecordingMessageReader(CreateEmptyInnerReader(), output, true))
         {
             Assert.Null(reader.Read());
         }
     }
 }
コード例 #3
0
        public void path_cannot_be_opened_or_modified_while_reader_has_it_open()
        {
            var path = Path.GetTempFileName();

            using(var reader = new RecordingMessageReader(CreateEmptyInnerReader(), path))
            {
                Assert.Throws<IOException>(() => File.Delete(path));
                Assert.Throws<IOException>(() => File.OpenRead(path).Dispose());
                Assert.Throws<IOException>(() => File.OpenWrite(path).Dispose());
            }

            File.Delete(path);
        }
コード例 #4
0
        public void reader_returns_messages_read_from_inner_reader()
        {
            var inner = CreatePopulatedInnerReader();
            var messages = inner.MessageQueue.ToArray();

            using(var reader = new RecordingMessageReader(inner, Stream.Null, false))
            {
                foreach(var expected in messages)
                {
                    Assert.Same(expected, reader.Read());
                }
                Assert.Null(reader.Read());
            }
        }
コード例 #5
0
        public void reader_records_messages_to_path()
        {
            var path = Path.GetTempFileName();

            using(var reader = new RecordingMessageReader(CreatePopulatedInnerReader(), path))
            {
                while(reader.Read() != null) { }
            }

            Assert.NotEqual(0L, new FileInfo(path).Length);

            File.Delete(path);
        }
コード例 #6
0
 public void reader_records_messages_to_output()
 {
     using(var output = new MemoryStream())
     {
         using(var reader = new RecordingMessageReader(CreatePopulatedInnerReader(), output, true))
         {
             while(reader.Read() != null) { }
             Assert.NotEqual(0L, output.Length);
         }
     }
 }
コード例 #7
0
        public void reader_does_not_return_the_set_next_message_delay_messages()
        {
            Message message;
            var path = Path.GetTempFileName();

            using(var reader = new RecordingMessageReader(CreatePopulatedInnerReader(), path))
            {
                while((message = reader.Read()) != null)
                {
                    Assert.IsNotType<SetNextMessageDelayMessage>(message);
                    Thread.Sleep(50);
                }
            }
        }
コード例 #8
0
        private Stream RecordMessages(TimeSpan insertDelay, params Message[] messages)
        {
            var output = new MemoryStream();

            using(var reader = new RecordingMessageReader(new StubMessageReader(messages), output, false))
            {
                while(reader.Read() != null)
                {
                    if(insertDelay > TimeSpan.Zero)
                    {
                        Thread.Sleep(insertDelay);
                    }
                }
            }

            output.Position = 0L;

            return output;
        }