14d959834f
* xunit unit tests * most pass with formatting * convert objects to xunit * remove nunit * format * merge fixes * switch objects to fluent assertions * update to fluent assertions * more FA * convert all to FA * Format * Fix tests * formatting * hopefully made credential test better * Catch more specific exception * use another more specific exception * Fix tests * update to xunit * update packages
45 lines
907 B
C#
45 lines
907 B
C#
using FluentAssertions;
|
|
using Speckle.Sdk.Dependencies;
|
|
using Speckle.Sdk.Serialisation.V2.Send;
|
|
using Xunit;
|
|
|
|
namespace Speckle.Sdk.Tests.Unit.Serialisation;
|
|
|
|
public class BatchTests
|
|
{
|
|
private class BatchItem : IHasSize
|
|
{
|
|
public BatchItem(int size)
|
|
{
|
|
Size = size;
|
|
}
|
|
|
|
public int Size { get; }
|
|
}
|
|
|
|
[Fact]
|
|
public void TestBatchSize_Calc()
|
|
{
|
|
using var batch = new Batch<BatchItem>();
|
|
batch.Add(new BatchItem(1));
|
|
batch.Size.Should().Be(1);
|
|
batch.Add(new BatchItem(2));
|
|
batch.Size.Should().Be(3);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestBatchSize_Trim()
|
|
{
|
|
using var batch = new Batch<BatchItem>();
|
|
batch.Add(new BatchItem(1));
|
|
batch.Add(new BatchItem(2));
|
|
batch.Size.Should().Be(3);
|
|
|
|
batch.Items.Capacity.Should().Be(Pools.DefaultCapacity);
|
|
batch.TrimExcess();
|
|
|
|
batch.Items.Capacity.Should().Be(2);
|
|
batch.Size.Should().Be(3);
|
|
}
|
|
}
|