Files
speckle-sharp-sdk/tests/Speckle.Sdk.Tests.Unit/Serialisation/ObjectModelDeprecationTests.cs
T
Jedd Morgan 06ef3e67e2 chore(deps): Correctly pin versions that need to be pinned and bump those that don't (#461)
* Correctly pin versions that need to be pinned and bump those that don't

* .NET logging alignment

* Fix test project dependencies

* recommended verify settings

* don't ask me why it needs this to work
2026-04-15 15:37:43 +01:00

49 lines
1.6 KiB
C#

using AwesomeAssertions;
using Speckle.Sdk.Host;
using Speckle.Sdk.Models;
using Speckle.Sdk.Serialisation.Deprecated;
namespace Speckle.Sdk.Tests.Unit.Serialisation
{
[Collection(nameof(RequiresTypeLoaderCollection))]
public class TypeLoaderTests
{
// Constructor replaces the [SetUp] functionality in NUnit
public TypeLoaderTests()
{
TypeLoader.ReInitialize(typeof(Base).Assembly, typeof(MySpeckleBase).Assembly);
}
[Fact] // Replaces [Test]
public void TestThatTypeWithoutAttributeFails()
{
// Record.Exception is the xUnit alternative of Assert.Throws
var exception = Record.Exception(() => TypeLoader.ParseType(typeof(string)));
exception.Should().NotBeNull(); // Shouldly assertion
exception.Should().BeOfType<InvalidOperationException>(); // Ensure it's the correct exception type
}
[Fact] // Replaces [Test]
public void TestThatTypeWithoutMultipleAttributes()
{
string destinationType = $"Speckle.Core.Serialisation.{nameof(MySpeckleBase)}";
var result = TypeLoader.GetAtomicType(destinationType);
result.Should().Be(typeof(MySpeckleBase)); // Shouldly assertion replaces Assert.That
destinationType = $"Speckle.Core.Serialisation.Deprecated.{nameof(MySpeckleBase)}";
result = TypeLoader.GetAtomicType(destinationType);
result.Should().Be(typeof(MySpeckleBase)); // Shouldly assertion replaces Assert.That
}
}
}
namespace Speckle.Sdk.Serialisation.Deprecated
{
[SpeckleType("Speckle.Core.Serialisation.MySpeckleBase")]
[DeprecatedSpeckleType("Speckle.Core.Serialisation.Deprecated.MySpeckleBase")]
public class MySpeckleBase : Base { }
}