/// <inheritdoc/>        
 protected override void ExecuteCore()
 {
     var path = Path.GetTempFileName();
     using(var reader = new RecordingMessageReader(CreateReader(), path))
     {
         while(reader.Read() != null) { }
     }
     MoveToTmsDirectory(path);
 }
 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());
         }
     }
 }
        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());
            }
        }
        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);
        }
 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);
         }
     }
 }
        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);
                }
            }
        }
        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;
        }