From 0318e18d7dc915c838306dacc163fb320cb5d57d Mon Sep 17 00:00:00 2001 From: adamnation Date: Tue, 11 Mar 2014 17:17:28 -0700 Subject: [PATCH 1/6] merge release/downloader-v1 into master. made some methods public so unit tests can run --- src/TerminalVelocity.Sharp/Downloader.cs | 10 +++++----- src/TerminalVelocity.Sharp/FailureToken.cs | 2 +- .../LargeFileDownloadParameters.cs | 2 +- .../SimpleHttpGetByRangeClient.cs | 2 +- .../TerminalVelocity.Tests.csproj | 3 +++ 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/TerminalVelocity.Sharp/Downloader.cs b/src/TerminalVelocity.Sharp/Downloader.cs index 89263e1..241a2a6 100644 --- a/src/TerminalVelocity.Sharp/Downloader.cs +++ b/src/TerminalVelocity.Sharp/Downloader.cs @@ -294,7 +294,7 @@ public static int ComputeProgressIndicator(long bytesWritten, long fileSize) } - internal Downloader(BufferManager bufferManager, + public Downloader(BufferManager bufferManager, ILargeFileDownloadParameters parameters, ConcurrentQueue writeQueue, ConcurrentStack readStack, @@ -431,7 +431,7 @@ internal static void ExecuteAndSquash( Action a) } } - internal static int ExpectedDownloadTimeInSeconds(int chunkSizeInBytes) + public static int ExpectedDownloadTimeInSeconds(int chunkSizeInBytes) { //so lets say 128Kbps per second with no overhead takes 62 seconds for 1MB 64kb = 16384bytes //20% latency @@ -443,12 +443,12 @@ internal static int ExpectedDownloadTimeInSeconds(int chunkSizeInBytes) } - internal static long GetChunkStart(int currentChunk, int maxChunkSize) + public static long GetChunkStart(int currentChunk, int maxChunkSize) { return currentChunk*(long)maxChunkSize; } - internal static int GetChunkCount(long fileSize, long chunkSize) + public static int GetChunkCount(long fileSize, long chunkSize) { if (chunkSize == 0) return 0; @@ -463,7 +463,7 @@ internal static int GetChunkCount(long fileSize, long chunkSize) return 1 + chunkCount; } - internal static int GetChunkSizeForCurrentChunk(long fileSize, int maxChunkSize, int zeroBasedChunkNumber) + public static int GetChunkSizeForCurrentChunk(long fileSize, int maxChunkSize, int zeroBasedChunkNumber) { int chunkCount = GetChunkCount(fileSize, maxChunkSize); diff --git a/src/TerminalVelocity.Sharp/FailureToken.cs b/src/TerminalVelocity.Sharp/FailureToken.cs index a172117..801a9fa 100644 --- a/src/TerminalVelocity.Sharp/FailureToken.cs +++ b/src/TerminalVelocity.Sharp/FailureToken.cs @@ -3,7 +3,7 @@ namespace Illumina.TerminalVelocity { - internal class FailureToken + public class FailureToken { public bool FailureDetected { get; private set; } diff --git a/src/TerminalVelocity.Sharp/LargeFileDownloadParameters.cs b/src/TerminalVelocity.Sharp/LargeFileDownloadParameters.cs index 9cd1843..41123c6 100644 --- a/src/TerminalVelocity.Sharp/LargeFileDownloadParameters.cs +++ b/src/TerminalVelocity.Sharp/LargeFileDownloadParameters.cs @@ -79,7 +79,7 @@ protected static FileStream CreateOutputStream(string filePath, long fileLength, return stream; } - internal static void EnsureCleanFile(string filePath, bool deleteIfExists) + public static void EnsureCleanFile(string filePath, bool deleteIfExists) { if ((File.Exists(filePath) && deleteIfExists) || !File.Exists(filePath)) { diff --git a/src/TerminalVelocity.Sharp/SimpleHttpGetByRangeClient.cs b/src/TerminalVelocity.Sharp/SimpleHttpGetByRangeClient.cs index cc9f168..f8f38fc 100644 --- a/src/TerminalVelocity.Sharp/SimpleHttpGetByRangeClient.cs +++ b/src/TerminalVelocity.Sharp/SimpleHttpGetByRangeClient.cs @@ -160,7 +160,7 @@ protected void EnsureConnection(Uri uri, bool forceRebuild = false) } - internal static string BuildHttpRequest(Uri uri, long start, long length) + public static string BuildHttpRequest(Uri uri, long start, long length) { string hostHeader; // see if they provided a port explicitly in the URI. If so, that must be set in the header diff --git a/tests/TerminalVelocity.Tests/TerminalVelocity.Tests.csproj b/tests/TerminalVelocity.Tests/TerminalVelocity.Tests.csproj index a1feafe..458de87 100644 --- a/tests/TerminalVelocity.Tests/TerminalVelocity.Tests.csproj +++ b/tests/TerminalVelocity.Tests/TerminalVelocity.Tests.csproj @@ -77,6 +77,9 @@ + + +