예제 #1
0
        public void CombineMultipleStreamParts()
        {
            const int size   = SizeOf64KByte + 1;
            var       stream = StreamHelper.GetStream(size);

            var streamParts = StreamPart.Create(stream);

            var combinedStream = StreamPart.Combine(streamParts);

            Assert.That(combinedStream.Length, Is.EqualTo(size));
        }
예제 #2
0
        public void CombineReturnsARewindedStream()
        {
            const int size   = SizeOf64KByte + 1;
            var       stream = StreamHelper.GetStream(size);

            var streamParts = StreamPart.Create(stream);

            var combinedStream = StreamPart.Combine(streamParts);

            Assert.That(combinedStream.Position, Is.EqualTo(0));
        }
예제 #3
0
        public void CombineMarksAllStreamPartsAsDisposed()
        {
            const int size   = SizeOf64KByte + 1;
            var       stream = StreamHelper.GetStream(size);

            var streamParts = StreamPart.Create(stream);

            var combinedStream = StreamPart.Combine(streamParts);

            // NOTE: The number of currently disposed stream parts is 1 and not 2 as one might
            //       have expected. This is due to the fact that the Combine method disposes the
            //       first stream part before creating the second one.
            Assert.That(StreamPartStatistics.StreamPartsCurrentlyDisposed, Is.EqualTo(1));

            Assert.That(StreamPartStatistics.StreamPartsCreatedTotal, Is.EqualTo(2));
            Assert.That(StreamPartStatistics.StreamPartsCreatedAsNew, Is.EqualTo(1));
            Assert.That(StreamPartStatistics.StreamPartsCreatedFromDisposed, Is.EqualTo(1));
        }
        public void RequestSilkveilWebsiteAsDownload()
        {
            this.IgnoreWhenInternetConnectionIsNotAvailable();

            var silkveilContainer = this._container.Resolve <ISilkveilContainer>();

            var streamParts = new List <IStreamPart>();

            silkveilContainer.ResponsePartAvailable += streamParts.Add;

            silkveilContainer.Handle("~/Download/00000000-0000-0000-0000-000000000000");

            using (var streamReader = new StreamReader(StreamPart.Combine(streamParts)))
            {
                Assert.That(streamReader.ReadToEnd(),
                            Contains.Substring("silkveil.net"));
            }
        }
예제 #5
0
 /// <summary>
 /// Merges the stream parts.
 /// </summary>
 /// <param name="streamParts">The stream parts.</param>
 public void Merge(IEnumerable <IStreamPart> streamParts)
 {
     this.OnStreamAvailable(StreamPart.Combine(streamParts));
 }