Files
speckle-sharp-sdk/tests/Speckle.Sdk.Tests.Unit/Serialisation/BatchTests.cs
T
Adam Hathcock 14d959834f Convert to Xunit (#196)
* 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
2025-01-09 15:32:28 +00:00

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);
}
}