Skip to content

Commit

Permalink
add chunk test to hit cover tests by 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
bezzad committed Sep 19, 2024
1 parent 93300c0 commit 8884dc3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/Downloader.Test/UnitTests/ChunkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/Downloader/ChunkDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
1 change: 1 addition & 0 deletions src/Downloader/DownloadProgressChangedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public DownloadProgressChangedEventArgs(string id)

/// <summary>
/// Gets the received bytes.
/// This property is filled when the EnableLiveStreaming option is true.
/// </summary>
/// <returns>A byte array that indicates the received bytes.</returns>
public byte[] ReceivedBytes { get; internal set; }
Expand Down

0 comments on commit 8884dc3

Please sign in to comment.