Files
speckle-sharp-sdk/tests/Speckle.Sdk.Serialization.Tests/ExplicitInterfaceTests.cs
T
Adam Hathcock 3aa993cecb Add cancellation tests (#218)
* Don't log cancelling

* redo exception handling for receive

* remove null test case

* clean up with Id/Json and more cancels

* Change the exception stacks

* fix serialization test

* make a custom scrubber for internalized exceptions

* clean up

* fix namespaces again :(

* adjust the scrubber

* try to make tests more predictable

* rework exceptions again

* strip out compile files used

* formatting

* custom exception validation

* fix init

* Move serialization to own class

* save serialize test

* add deep clean

* add cancellation test on save to cache

* cancellation tests

* format

* do DI correctly

* receive cancel works
2025-01-30 13:42:15 +00:00

60 lines
1.6 KiB
C#

using Microsoft.Extensions.Logging.Abstractions;
using Speckle.Sdk.Host;
using Speckle.Sdk.Models;
using Speckle.Sdk.Serialisation.V2.Send;
namespace Speckle.Sdk.Serialization.Tests;
public class ExplicitInterfaceTests
{
public ExplicitInterfaceTests()
{
TypeLoader.Reset();
TypeLoader.Initialize(typeof(Base).Assembly, typeof(TestClass).Assembly);
}
[Fact]
public async Task Test_Json()
{
var testClass = new TestClass() { RegularProperty = "Hello" };
var objects = new Dictionary<string, string>();
using var process2 = new SerializeProcess(
null,
new DummySendCacheManager(objects),
new DummyServerObjectManager(),
new BaseChildFinder(new BasePropertyGatherer()),
new BaseSerializer(new DummySendCacheManager(objects), new ObjectSerializerFactory(new BasePropertyGatherer())),
new NullLoggerFactory(),
default,
new SerializeProcessOptions(false, false, true, true)
);
await process2.Serialize(testClass);
await VerifyJsonDictionary(objects);
}
[Fact]
public async Task Test_ExtractAllProperties()
{
var testClass = new TestClass() { RegularProperty = "Hello" };
var gatherer = new BasePropertyGatherer();
var properties = gatherer.ExtractAllProperties(testClass).ToList();
await Verify(properties);
}
}
[SpeckleType("Speckle.Core.Serialisation.TestClass")]
public sealed class TestClass : Base, ITestInterface
{
public string RegularProperty { get; set; }
string ITestInterface.TestProperty => RegularProperty;
}
public interface ITestInterface
{
string TestProperty { get; }
}