d305fe59cb
* First pass of ObjectSaver and better in-memory usage * fix some tests * add commit to match deserialize process * correct more tests * format * make a deserialize factory * fix tests? and format * use distinct * Fix mismerge * Fix serialization issues with tests * fix merges * follow copilot suggestions * remove disables * change registration to take strings and TypeLoader isn't public * remove unused transports * more test fixes * fmt * add Application object back
64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
using System.Collections.Concurrent;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Speckle.Sdk.Models;
|
|
using Speckle.Sdk.Serialisation;
|
|
using Speckle.Sdk.Serialisation.V2;
|
|
using Speckle.Sdk.Serialisation.V2.Send;
|
|
|
|
namespace Speckle.Sdk.Serialization.Tests;
|
|
|
|
public class ExplicitInterfaceTests
|
|
{
|
|
private readonly ISerializeProcessFactory _factory;
|
|
|
|
public ExplicitInterfaceTests()
|
|
{
|
|
var serviceCollection = new ServiceCollection();
|
|
serviceCollection.AddSpeckleSdk(new("Tests", "test"), "v3", typeof(TestClass).Assembly);
|
|
var serviceProvider = serviceCollection.BuildServiceProvider();
|
|
|
|
_factory = serviceProvider.GetRequiredService<ISerializeProcessFactory>();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Test_Json()
|
|
{
|
|
var testClass = new TestClass() { RegularProperty = "Hello" };
|
|
|
|
var objects = new ConcurrentDictionary<string, string>();
|
|
await using var serializeProcess = _factory.CreateSerializeProcess(
|
|
new ConcurrentDictionary<Id, Json>(),
|
|
objects,
|
|
null,
|
|
default,
|
|
new SerializeProcessOptions(true, true, false, true)
|
|
);
|
|
|
|
await serializeProcess.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; }
|
|
}
|