public void InnerStreamIsWrappedByMarkableStream()
 {
     using (var stream = new TrackingStream(new MemoryStream(_content)))
     {
         stream.AsMarkable();
         Assert.That(Reflector.GetProperty(stream, "InnerStream"), Is.InstanceOf <MarkableForwardOnlyEventingReadStream>());
     }
 }
        public void CaptureSetupResetMarkablePosition()
        {
            using (var stream = new TrackingStream(new MemoryStream(_content)))
            {
                var ms = stream.AsMarkable();
                ms.Drain();
                Assert.That(stream.Position, Is.EqualTo(_content.Length));

                stream.SetupCapture(new MessageBodyCaptureDescriptor("some-data", MessageBodyCaptureMode.Unclaimed));
                Assert.That(stream.Position, Is.EqualTo(0));
            }
        }
        public void EventsAreNotFiredThroughMarkableInnerStream()
        {
            using (var stream = new TrackingStream(new MemoryStream(_content)))
            {
                var edgeEventsCount = 0;
                stream.AfterLastReadEvent   += (sender, args) => ++ edgeEventsCount;
                stream.BeforeFirstReadEvent += (sender, args) => ++ edgeEventsCount;
                var eventsCount = 0;
                stream.ReadEvent += (sender, args) => ++ eventsCount;

                var markableForwardOnlyEventingReadStream = stream.AsMarkable();
                Assert.That(edgeEventsCount, Is.EqualTo(0));
                Assert.That(eventsCount, Is.EqualTo(0));

                markableForwardOnlyEventingReadStream.Drain();
                Assert.That(edgeEventsCount, Is.EqualTo(0));
                Assert.That(eventsCount, Is.EqualTo(0));
            }
        }