Files
speckle-sharp-sdk/tests/Speckle.Objects.Tests.Unit/ObjectBaseValidityTests.cs
T
Adam Hathcock 14d959834f Convert to Xunit (#196)
* 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
2025-01-09 15:32:28 +00:00

45 lines
1.3 KiB
C#

using FluentAssertions;
using Speckle.Objects.Geometry;
using Speckle.Objects.Geometry.Autocad;
using Speckle.Sdk.Host;
using Speckle.Sdk.Models;
using Xunit;
using Point = Speckle.Objects.Geometry.Point;
namespace Speckle.Objects.Tests.Unit;
public class ObjectBaseValidityTests
{
[Fact]
public void TestThatTypeWithoutAttributeFails()
{
TypeLoader.Reset();
TypeLoader.Initialize(typeof(Base).Assembly, typeof(Point).Assembly);
}
[Fact]
public void InheritanceTest_Disallow()
{
var exception = Assert.Throws<InvalidOperationException>(() =>
{
TypeLoader.Reset();
TypeLoader.Initialize(typeof(Base).Assembly, typeof(Point).Assembly, typeof(Test).Assembly);
});
exception.Should().NotBeNull();
exception
.Message.Should()
.Be("Speckle.Objects.Tests.Unit.ObjectBaseValidityTests+Test inherits from Base has no SpeckleTypeAttribute");
}
[Fact]
public void InheritanceTest_Allow()
{
TypeLoader.Reset();
TypeLoader.Initialize(typeof(Base).Assembly, typeof(Point).Assembly);
var fullTypeString = TypeLoader.GetFullTypeString(typeof(AutocadPolycurve));
fullTypeString.Should().Be("Objects.Geometry.Polycurve:Objects.Geometry.Autocad.AutocadPolycurve");
}
public class Test : Polycurve;
}