14d959834f
* xunit unit tests * most pass with formatting * convert objects to xunit * remove nunit * format * merge fixes * switch objects to fluent assertions * update to fluent assertions * more FA * convert all to FA * Format * Fix tests * formatting * hopefully made credential test better * Catch more specific exception * use another more specific exception * Fix tests * update to xunit * update packages
50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
using FluentAssertions;
|
|
using Speckle.Sdk.Host;
|
|
using Speckle.Sdk.Models;
|
|
using Speckle.Sdk.Serialisation.Deprecated;
|
|
using Xunit;
|
|
|
|
namespace Speckle.Sdk.Tests.Unit.Serialisation
|
|
{
|
|
public class TypeLoaderTests
|
|
{
|
|
// Constructor replaces the [SetUp] functionality in NUnit
|
|
public TypeLoaderTests()
|
|
{
|
|
TypeLoader.Reset();
|
|
TypeLoader.Initialize(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 { }
|
|
}
|