diff --git a/Directory.Packages.props b/Directory.Packages.props index 3ef1f4bb..3f941964 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,6 +1,6 @@ - + diff --git a/tests/Speckle.Objects.Tests.Unit/packages.lock.json b/tests/Speckle.Objects.Tests.Unit/packages.lock.json index 6b3de7b8..2681856b 100644 --- a/tests/Speckle.Objects.Tests.Unit/packages.lock.json +++ b/tests/Speckle.Objects.Tests.Unit/packages.lock.json @@ -4,9 +4,9 @@ "net8.0": { "altcover": { "type": "Direct", - "requested": "[8.8.74, )", - "resolved": "8.8.74", - "contentHash": "e8RZNE0vZnuBk/gOAWu9K5wm3S7dOrOlZje3PHI9PJUHqvP1cxVJD1eXAAmddFVlixowB7C7/zvC16GnunC2LQ==" + "requested": "[8.8.173, )", + "resolved": "8.8.173", + "contentHash": "iejmqWdC9H9ShTtsT7vSLpZ74RG4sDhheW7wllczXWl6WZAaCqGXMFGRRHi8TZGCzV/7Ah5gjXZ4GRlfAef4Eg==" }, "GitVersion.MsBuild": { "type": "Direct", diff --git a/tests/Speckle.Sdk.Serialization.Tests/packages.lock.json b/tests/Speckle.Sdk.Serialization.Tests/packages.lock.json index 6b3de7b8..2681856b 100644 --- a/tests/Speckle.Sdk.Serialization.Tests/packages.lock.json +++ b/tests/Speckle.Sdk.Serialization.Tests/packages.lock.json @@ -4,9 +4,9 @@ "net8.0": { "altcover": { "type": "Direct", - "requested": "[8.8.74, )", - "resolved": "8.8.74", - "contentHash": "e8RZNE0vZnuBk/gOAWu9K5wm3S7dOrOlZje3PHI9PJUHqvP1cxVJD1eXAAmddFVlixowB7C7/zvC16GnunC2LQ==" + "requested": "[8.8.173, )", + "resolved": "8.8.173", + "contentHash": "iejmqWdC9H9ShTtsT7vSLpZ74RG4sDhheW7wllczXWl6WZAaCqGXMFGRRHi8TZGCzV/7Ah5gjXZ4GRlfAef4Eg==" }, "GitVersion.MsBuild": { "type": "Direct", diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs index 784f9ee6..4cf9ec3b 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs @@ -6,7 +6,7 @@ namespace Speckle.Sdk.Tests.Integration.API.GraphQL.Resources; [TestOf(typeof(SubscriptionResource))] -public class SubscriptionResourceTests +public class SubscriptionResourceTests : IDisposable { private const int WAIT_PERIOD = 300; private Client _testUser; @@ -117,4 +117,7 @@ public async Task ProjectCommentsUpdated_SubscriptionIsCalled() Assert.That(subscriptionMessage, Is.Not.Null); Assert.That(subscriptionMessage!.id, Is.EqualTo(created.id)); } + + [OneTimeTearDown] + public void Dispose() => _testUser.Dispose(); } diff --git a/tests/Speckle.Sdk.Tests.Integration/packages.lock.json b/tests/Speckle.Sdk.Tests.Integration/packages.lock.json index ce249d81..c31c21b1 100644 --- a/tests/Speckle.Sdk.Tests.Integration/packages.lock.json +++ b/tests/Speckle.Sdk.Tests.Integration/packages.lock.json @@ -4,9 +4,9 @@ "net8.0": { "altcover": { "type": "Direct", - "requested": "[8.8.74, )", - "resolved": "8.8.74", - "contentHash": "e8RZNE0vZnuBk/gOAWu9K5wm3S7dOrOlZje3PHI9PJUHqvP1cxVJD1eXAAmddFVlixowB7C7/zvC16GnunC2LQ==" + "requested": "[8.8.173, )", + "resolved": "8.8.173", + "contentHash": "iejmqWdC9H9ShTtsT7vSLpZ74RG4sDhheW7wllczXWl6WZAaCqGXMFGRRHi8TZGCzV/7Ah5gjXZ4GRlfAef4Eg==" }, "GitVersion.MsBuild": { "type": "Direct", @@ -233,7 +233,7 @@ "Shouldly": "[4.2.1, )", "Speckle.DoubleNumerics": "[4.0.1, )", "Speckle.Sdk": "[1.0.0, )", - "altcover": "[8.8.74, )" + "altcover": "[8.8.173, )" } }, "GraphQL.Client": { diff --git a/tests/Speckle.Sdk.Tests.Unit/Common/NotNullTests.cs b/tests/Speckle.Sdk.Tests.Unit/Common/NotNullTests.cs index 680cf666..169b36cf 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Common/NotNullTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Common/NotNullTests.cs @@ -43,6 +43,20 @@ public async Task NotNullStruct_Task() t.ShouldBe(2); } + [Test] + public async Task NotNullClass_ValueTask() + { + var t = await NotNullExtensions.NotNull(ValueTask.FromResult("test")); + t.ShouldNotBeNull().ShouldBe("test"); + } + + [Test] + public async Task NotNullStruct_ValueTask() + { + var t = await NotNullExtensions.NotNull(ValueTask.FromResult(2)); + t.ShouldBe(2); + } + [Test] public void NotNullClass_Exception() => Assert.Throws(() => NotNullExtensions.NotNull((string?)null)); @@ -58,4 +72,16 @@ public void NotNullClass_Task_Exception() => [Test] public void NotNullStruct_Task_Exception() => Assert.ThrowsAsync(() => NotNullExtensions.NotNull(Task.FromResult((int?)null))); + + [Test] + public void NotNullClass_ValueTask_Exception() => + Assert.ThrowsAsync( + async () => await NotNullExtensions.NotNull(ValueTask.FromResult((string?)null)) + ); + + [Test] + public void NotNullStruct_ValueTask_Exception() => + Assert.ThrowsAsync( + async () => await NotNullExtensions.NotNull(ValueTask.FromResult((int?)null)) + ); } diff --git a/tests/Speckle.Sdk.Tests.Unit/Common/UnitsTest.cs b/tests/Speckle.Sdk.Tests.Unit/Common/UnitsTest.cs index 054c5601..938d3a7e 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Common/UnitsTest.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Common/UnitsTest.cs @@ -8,11 +8,15 @@ public class UnitsTest { private const double EPS = 0.00022; + public static List OfficiallySupportedUnits => Units.SupportedUnits; + public static List NotSupportedUnits => ["feeters", "liters", "us_ft"]; + public static List ConversionSupport => [.. Units.SupportedUnits, null]; + [Test, Combinatorial] [DefaultFloatingPointTolerance(EPS)] public void TestUnitConversion( - [ValueSource(typeof(Units), nameof(Units.SupportedUnits))] string from, - [ValueSource(typeof(Units), nameof(Units.SupportedUnits))] string to + [ValueSource(nameof(ConversionSupport))] string? from, + [ValueSource(nameof(ConversionSupport))] string? to ) { var forwards = Units.GetConversionFactor(from, to); @@ -24,4 +28,43 @@ public void TestUnitConversion( $"Behaviour says that 1{from} == {forwards}{to}, and 1{to} == {backwards}{from}" ); } + + [TestCaseSource(nameof(OfficiallySupportedUnits))] + public void IsUnitSupported_ReturnsTrue_AllSupportedUnits(string unit) + { + bool res = Units.IsUnitSupported(unit); + Assert.That(res, Is.True); + } + + [TestCaseSource(nameof(NotSupportedUnits))] + public void IsUnitSupported_ReturnsFalse_NotSupportedUnits(string unit) + { + bool res = Units.IsUnitSupported(unit); + Assert.That(res, Is.False); + } + + [TestCaseSource(nameof(OfficiallySupportedUnits))] + public void GetUnitsFromString_ReturnsSupported(string unit) + { + var lower = Units.GetUnitsFromString(unit); + var upper = Units.GetUnitsFromString(unit?.ToUpperInvariant()); + + Assert.That(lower, Is.EqualTo(unit)); + Assert.That(upper, Is.EqualTo(unit)); + } + + [TestCaseSource(nameof(NotSupportedUnits))] + public void GetUnitsFromString_ThrowsUnSupported(string unit) + { + Assert.Throws(() => _ = Units.GetUnitsFromString(unit)); + } + + [TestCaseSource(nameof(OfficiallySupportedUnits))] + public void UnitEncoding_RoundTrip(string unit) + { + var encoded = Units.GetEncodingFromUnit(unit); + var res = Units.GetUnitFromEncoding(encoded); + + Assert.That(res, Is.EqualTo(unit)); + } } diff --git a/tests/Speckle.Sdk.Tests.Unit/packages.lock.json b/tests/Speckle.Sdk.Tests.Unit/packages.lock.json index 2dd713eb..c012b969 100644 --- a/tests/Speckle.Sdk.Tests.Unit/packages.lock.json +++ b/tests/Speckle.Sdk.Tests.Unit/packages.lock.json @@ -4,9 +4,9 @@ "net8.0": { "altcover": { "type": "Direct", - "requested": "[8.8.74, )", - "resolved": "8.8.74", - "contentHash": "e8RZNE0vZnuBk/gOAWu9K5wm3S7dOrOlZje3PHI9PJUHqvP1cxVJD1eXAAmddFVlixowB7C7/zvC16GnunC2LQ==" + "requested": "[8.8.173, )", + "resolved": "8.8.173", + "contentHash": "iejmqWdC9H9ShTtsT7vSLpZ74RG4sDhheW7wllczXWl6WZAaCqGXMFGRRHi8TZGCzV/7Ah5gjXZ4GRlfAef4Eg==" }, "GitVersion.MsBuild": { "type": "Direct",