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)); }
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)); }
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")); } }
/// <summary> /// Merges the stream parts. /// </summary> /// <param name="streamParts">The stream parts.</param> public void Merge(IEnumerable <IStreamPart> streamParts) { this.OnStreamAvailable(StreamPart.Combine(streamParts)); }