From 8884dc37f878d65aa27836ebd5d11f7aa6060e4a Mon Sep 17 00:00:00 2001 From: bezzad Date: Thu, 19 Sep 2024 17:47:27 +0330 Subject: [PATCH] add chunk test to hit cover tests by 100% --- src/Downloader.Test/UnitTests/ChunkTest.cs | 22 ++++++++++++++++++- src/Downloader/ChunkDownloader.cs | 2 +- .../DownloadProgressChangedEventArgs.cs | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Downloader.Test/UnitTests/ChunkTest.cs b/src/Downloader.Test/UnitTests/ChunkTest.cs index d5e48c85..efafe115 100644 --- a/src/Downloader.Test/UnitTests/ChunkTest.cs +++ b/src/Downloader.Test/UnitTests/ChunkTest.cs @@ -185,4 +185,24 @@ public void ChunkSerializationTest() chunk.Clear(); } -} + + [Fact] + public void TestCanWriteWhenChunkIsNotFull() + { + // arrange + var chunk = new Chunk(0, 1000) { Position = 120 }; + + // assert + Assert.True(chunk.CanWrite); + } + + [Fact] + public void TestCanWriteWhenChunkIsFull() + { + // arrange + var chunk = new Chunk(0, 1000) { Position = 1000 }; + + // assert + Assert.False(chunk.CanWrite); + } +} \ No newline at end of file diff --git a/src/Downloader/ChunkDownloader.cs b/src/Downloader/ChunkDownloader.cs index 22efca87..c8053e82 100644 --- a/src/Downloader/ChunkDownloader.cs +++ b/src/Downloader/ChunkDownloader.cs @@ -120,7 +120,7 @@ private async Task DownloadChunk(Request downloadRequest, PauseToken pauseToken, private void SetRequestRange(HttpWebRequest request) { - var startOffset = Chunk.Start + Chunk.Position; + long startOffset = Chunk.Start + Chunk.Position; // has limited range if (Chunk.End > 0 && diff --git a/src/Downloader/DownloadProgressChangedEventArgs.cs b/src/Downloader/DownloadProgressChangedEventArgs.cs index 361e1131..10b447cc 100644 --- a/src/Downloader/DownloadProgressChangedEventArgs.cs +++ b/src/Downloader/DownloadProgressChangedEventArgs.cs @@ -58,6 +58,7 @@ public DownloadProgressChangedEventArgs(string id) /// /// Gets the received bytes. + /// This property is filled when the EnableLiveStreaming option is true. /// /// A byte array that indicates the received bytes. public byte[] ReceivedBytes { get; internal set; }