-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e3c47b
commit 79d7ab9
Showing
3 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using NUnit.Framework; | ||
using Shouldly; | ||
using Speckle.Sdk.Serialisation.V2.Send; | ||
|
||
namespace Speckle.Sdk.Tests.Unit.Serialisation; | ||
|
||
[TestFixture] | ||
public class BatchTests | ||
{ | ||
private class BatchItem : IHasSize | ||
{ | ||
public BatchItem(int size) | ||
{ | ||
Size = size; | ||
} | ||
|
||
public int Size { get; } | ||
} | ||
|
||
[Test] | ||
public void TestBatchSize_Calc() | ||
{ | ||
var batch = new Batch<BatchItem>(4); | ||
batch.Add(new BatchItem(1)); | ||
batch.Size.ShouldBe(1); | ||
batch.Add(new BatchItem(2)); | ||
batch.Size.ShouldBe(3); | ||
} | ||
|
||
[Test] | ||
public void TestBatchSize_Trim() | ||
{ | ||
var batch = new Batch<BatchItem>(4); | ||
batch.Add(new BatchItem(1)); | ||
batch.Add(new BatchItem(2)); | ||
batch.Size.ShouldBe(3); | ||
|
||
batch.Items.Capacity.ShouldBe(4); | ||
batch.TrimExcess(); | ||
|
||
batch.Items.Capacity.ShouldBe(2); | ||
batch.Size.ShouldBe(3); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters