Files
speckle-sharp-sdk/tests/Speckle.Sdk.Tests.Unit/Serialisation/ObjectModelDeprecationTests.cs
T
Adam Hathcock 6f5f044095 Adam/cxpla 6 kill remaining kit code in core (#59)
* compiles with relevant deletions

* Test fixes

* fix type loading

* type load for tests

* speckle objects renamespace

* rename Core to Sdk

* Fix test references

* tests renaming

* rename logging

* fmt

* start of adding an attribute to all base types

* convert all types and do basic test

* Fix most tests

* fix more tests

* fmt

* Build fix

* add changes and more tests

* Fix tests

* Fix integration tests
2024-08-08 10:52:19 +01:00

50 lines
1.4 KiB
C#

using NUnit.Framework;
using Shouldly;
using Speckle.Sdk.Host;
using Speckle.Sdk.Models;
using Speckle.Sdk.Serialisation.Deprecated;
using Speckle.Sdk.Serialisation.SerializationUtilities;
namespace Speckle.Sdk.Tests.Unit.Serialisation
{
[TestFixture]
[TestOf(typeof(BaseObjectSerializationUtilities))]
public class ObjectModelDeprecationTests
{
[SetUp]
public void Setup()
{
TypeLoader.Reset();
TypeLoader.Initialize(typeof(Base).Assembly, typeof(MySpeckleBase).Assembly);
}
[Test]
public void TestThatTypeWithoutAttributeFails()
{
var e = Assert.Throws<InvalidOperationException>(() => TypeLoader.ParseType(typeof(string)));
e.ShouldNotBeNull();
}
[Test]
public void TestThatTypeWithoutMultipleAttributes()
{
string destinationType = $"Speckle.Core.Serialisation.{nameof(MySpeckleBase)}";
var result = TypeLoader.GetAtomicType(destinationType);
Assert.That(result, Is.EqualTo(typeof(MySpeckleBase)));
destinationType = $"Speckle.Core.Serialisation.Deprecated.{nameof(MySpeckleBase)}";
result = TypeLoader.GetAtomicType(destinationType);
Assert.That(result, Is.EqualTo(typeof(MySpeckleBase)));
}
}
}
namespace Speckle.Sdk.Serialisation.Deprecated
{
[SpeckleType("Speckle.Core.Serialisation.MySpeckleBase")]
[DeprecatedSpeckleType("Speckle.Core.Serialisation.Deprecated.MySpeckleBase")]
public class MySpeckleBase : Base { }
}