Files
speckle-sharp-sdk/tests/Speckle.Sdk.Tests.Unit/Serialisation/SimpleRoundTripTests.cs
T
Adam Hathcock 1fe1a54dcf Custom task scheduler for serialization, fix batch size calc (#194)
* Add a custom task scheduler

* Better usage, don't wait to enqueue to save to channels

* Completely pre-cal batch size to avoid spinning issues

* Try to fix cache counting

* properly dispose things

* format

* clean up

* adjust count and save on current thread

* move batch it's own file

* update a few packages

* fix build and add batch tests
2025-01-03 12:26:19 +00:00

57 lines
1.3 KiB
C#

using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using Speckle.Sdk.Api;
using Speckle.Sdk.Host;
using Speckle.Sdk.Models;
using Speckle.Sdk.Tests.Unit.Host;
namespace Speckle.Sdk.Tests.Unit.Serialisation;
[TestFixture]
public class SimpleRoundTripTests
{
private IOperations _operations;
static SimpleRoundTripTests()
{
Reset();
}
private static void Reset()
{
TypeLoader.Reset();
TypeLoader.Initialize(typeof(Base).Assembly, Assembly.GetExecutingAssembly());
}
public static IEnumerable<Base> TestData()
{
yield return new DiningTable { ["@strangeVariable_NAme3"] = new TableLegFixture() };
var polyline = new Polyline();
for (int i = 0; i < 100; i++)
{
polyline.Points.Add(new Point { X = i * 2, Y = i % 2 });
}
yield return polyline;
}
[SetUp]
public void Setup()
{
Reset();
var serviceProvider = TestServiceSetup.GetServiceProvider();
_operations = serviceProvider.GetRequiredService<IOperations>();
}
[TestCaseSource(nameof(TestData))]
public async Task SimpleSerialization(Base testData)
{
var result = _operations.Serialize(testData);
var test = await _operations.DeserializeAsync(result);
Assert.That(testData.GetId(), Is.EqualTo(test.GetId()));
}
}