From eb5cc7a8af9615fe4c76e8c168979f376250a132 Mon Sep 17 00:00:00 2001 From: Matt Edmondson Date: Tue, 13 Jan 2026 12:15:15 +1100 Subject: [PATCH] Remove Polyfill package references and update test assertions for clarity --- .../Semantics.Quantities.csproj | 3 --- Semantics.Strings/Semantics.Strings.csproj | 3 --- Semantics.Test/Parallelization.cs | 5 +++++ Semantics.Test/Paths/PathIntegrationTests.cs | 12 +++++----- Semantics.Test/PhysicalQuantityCoreTests.cs | 4 ++-- Semantics.Test/ReflectionCoefficientTests.cs | 2 +- Semantics.Test/SemanticPathInterfaceTests.cs | 22 +++++++++---------- Semantics.Test/SemanticStringTests.cs | 6 ++--- Semantics.Test/Semantics.Test.csproj | 4 +--- 9 files changed, 29 insertions(+), 32 deletions(-) create mode 100644 Semantics.Test/Parallelization.cs diff --git a/Semantics.Quantities/Semantics.Quantities.csproj b/Semantics.Quantities/Semantics.Quantities.csproj index e8264e9..f4a7ce5 100644 --- a/Semantics.Quantities/Semantics.Quantities.csproj +++ b/Semantics.Quantities/Semantics.Quantities.csproj @@ -5,8 +5,5 @@ net9.0;net8.0;net7.0; - - - diff --git a/Semantics.Strings/Semantics.Strings.csproj b/Semantics.Strings/Semantics.Strings.csproj index 579ac6f..e08e5c4 100644 --- a/Semantics.Strings/Semantics.Strings.csproj +++ b/Semantics.Strings/Semantics.Strings.csproj @@ -9,8 +9,5 @@ - - - diff --git a/Semantics.Test/Parallelization.cs b/Semantics.Test/Parallelization.cs new file mode 100644 index 0000000..bd736af --- /dev/null +++ b/Semantics.Test/Parallelization.cs @@ -0,0 +1,5 @@ +// Copyright (c) ktsu.dev +// All rights reserved. +// Licensed under the MIT license. + +[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)] diff --git a/Semantics.Test/Paths/PathIntegrationTests.cs b/Semantics.Test/Paths/PathIntegrationTests.cs index f7d5d20..9c178ad 100644 --- a/Semantics.Test/Paths/PathIntegrationTests.cs +++ b/Semantics.Test/Paths/PathIntegrationTests.cs @@ -26,7 +26,7 @@ public void MixedPathTypes_InCollection_WorkCorrectly() FilePath.Create("any.txt") ]; - Assert.AreEqual(6, paths.Count); + Assert.HasCount(6, paths); foreach (IPath path in paths) { Assert.IsNotNull(path); @@ -45,8 +45,8 @@ public void DirectoryNames_InCollection_WorkCorrectly() DirectoryName.Create("folder3") ]; - Assert.AreEqual(3, names.Count); - Assert.IsTrue(names.Contains(DirectoryName.Create("folder1"))); + Assert.HasCount(3, names); + Assert.Contains(DirectoryName.Create("folder1"), names); } [TestMethod] @@ -60,7 +60,7 @@ public void DirectoryNames_AsSet_WorkCorrectly() DirectoryName.Create("folder1") // Duplicate ]; - Assert.AreEqual(2, uniqueNames.Count); // Duplicate should be ignored + Assert.HasCount(2, uniqueNames); // Duplicate should be ignored } [TestMethod] @@ -185,8 +185,8 @@ public void DirectoryDepth_Comparison_WorksCorrectly() RelativeDirectoryPath medium = RelativeDirectoryPath.Create(@"a\b"); RelativeDirectoryPath deep = RelativeDirectoryPath.Create(@"a\b\c"); - Assert.IsTrue(shallow.Depth < medium.Depth); - Assert.IsTrue(medium.Depth < deep.Depth); + Assert.IsLessThan(medium.Depth, shallow.Depth); + Assert.IsLessThan(deep.Depth, medium.Depth); Assert.AreEqual(0, shallow.Depth); Assert.AreEqual(1, medium.Depth); Assert.AreEqual(2, deep.Depth); diff --git a/Semantics.Test/PhysicalQuantityCoreTests.cs b/Semantics.Test/PhysicalQuantityCoreTests.cs index d79f921..8505a38 100644 --- a/Semantics.Test/PhysicalQuantityCoreTests.cs +++ b/Semantics.Test/PhysicalQuantityCoreTests.cs @@ -34,8 +34,8 @@ public void CompareTo_And_Equals_Behavior() { Length a = Length.Create(1.0); Length b = Length.Create(2.0); - Assert.IsTrue(a.CompareTo(b) < 0); - Assert.IsTrue(b.CompareTo(a) > 0); + Assert.IsLessThan(0, a.CompareTo(b)); + Assert.IsGreaterThan(0, b.CompareTo(a)); Assert.IsTrue(a.Equals(Length.Create(1.0))); IPhysicalQuantity other = new FakeQuantity(); diff --git a/Semantics.Test/ReflectionCoefficientTests.cs b/Semantics.Test/ReflectionCoefficientTests.cs index 7932212..3a390e0 100644 --- a/Semantics.Test/ReflectionCoefficientTests.cs +++ b/Semantics.Test/ReflectionCoefficientTests.cs @@ -49,7 +49,7 @@ public void AtObliqueIncidence_ShouldReduceReflectionComparedToNormal_ForSmallAn ReflectionCoefficient rOblique = ReflectionCoefficient.AtObliqueIncidence(angleRad, ratio); double rNormal = (ratio - 1.0) / (ratio + 1.0); - Assert.IsTrue(rOblique.Value < rNormal); + Assert.IsLessThan(rNormal, rOblique.Value); } } diff --git a/Semantics.Test/SemanticPathInterfaceTests.cs b/Semantics.Test/SemanticPathInterfaceTests.cs index a6f52ff..411c07e 100644 --- a/Semantics.Test/SemanticPathInterfaceTests.cs +++ b/Semantics.Test/SemanticPathInterfaceTests.cs @@ -432,17 +432,17 @@ public void DirectoryPath_Contents_ReturnsCorrectPathTypes() DirectoryPath dirPath = DirectoryPath.Create(testDir); IPath[] contents = [.. dirPath.GetContents()]; - Assert.IsTrue(contents.Length > 0, "Contents should not be empty"); - Assert.AreEqual(3, contents.Length, "Should contain 2 files and 1 directory"); + Assert.IsNotEmpty(contents, "Contents should not be empty"); + Assert.HasCount(3, contents, "Should contain 2 files and 1 directory"); // Verify file types IFilePath[] files = [.. contents.OfType()]; - Assert.AreEqual(2, files.Length, "Should contain 2 files"); + Assert.HasCount(2, files, "Should contain 2 files"); Assert.IsTrue(files.All(f => f is FilePath), "Files should be FilePath type"); // Verify directory types IDirectoryPath[] directories = [.. contents.OfType()]; - Assert.AreEqual(1, directories.Length, "Should contain 1 directory"); + Assert.HasCount(1, directories, "Should contain 1 directory"); Assert.IsTrue(directories.All(d => d is DirectoryPath), "Directories should be DirectoryPath type"); } finally @@ -475,17 +475,17 @@ public void AbsoluteDirectoryPath_Contents_ReturnsAbsolutePathTypes() AbsoluteDirectoryPath absDir = AbsoluteDirectoryPath.Create(testDir); IPath[] contents = [.. absDir.GetContents()]; - Assert.IsTrue(contents.Length > 0, "Contents should not be empty"); - Assert.AreEqual(2, contents.Length, "Should contain 1 file and 1 directory"); + Assert.IsNotEmpty(contents, "Contents should not be empty"); + Assert.HasCount(2, contents, "Should contain 1 file and 1 directory"); // Verify file types are absolute IAbsoluteFilePath[] absoluteFiles = [.. contents.OfType()]; - Assert.AreEqual(1, absoluteFiles.Length, "Should contain 1 absolute file"); + Assert.HasCount(1, absoluteFiles, "Should contain 1 absolute file"); Assert.IsTrue(absoluteFiles.All(f => f is AbsoluteFilePath), "Files should be AbsoluteFilePath type"); // Verify directory types are absolute IAbsoluteDirectoryPath[] absoluteDirectories = [.. contents.OfType()]; - Assert.AreEqual(1, absoluteDirectories.Length, "Should contain 1 absolute directory"); + Assert.HasCount(1, absoluteDirectories, "Should contain 1 absolute directory"); Assert.IsTrue(absoluteDirectories.All(d => d is AbsoluteDirectoryPath), "Directories should be AbsoluteDirectoryPath type"); } finally @@ -554,12 +554,12 @@ public void DirectoryPath_Contents_PolymorphicUsage() IEnumerable contents = dirPath.GetContents(); List contentsList = [.. contents]; - Assert.IsTrue(contentsList.Count != 0, "Contents should not be empty"); - Assert.AreEqual(2, contentsList.Count, "Should contain 2 files"); + Assert.IsNotEmpty(contentsList, "Contents should not be empty"); + Assert.HasCount(2, contentsList, "Should contain 2 files"); // Test filtering by type IFilePath[] files = [.. contents.OfType()]; - Assert.AreEqual(2, files.Length, "Should be able to filter files polymorphically"); + Assert.HasCount(2, files, "Should be able to filter files polymorphically"); // Test that all returned items are paths Assert.IsTrue(contentsList.All(item => item is not null), "All contents should implement IPath"); diff --git a/Semantics.Test/SemanticStringTests.cs b/Semantics.Test/SemanticStringTests.cs index 20deea6..e1ac52d 100644 --- a/Semantics.Test/SemanticStringTests.cs +++ b/Semantics.Test/SemanticStringTests.cs @@ -302,7 +302,7 @@ public void StaticToCharArray_WithNullSemanticString() { MySemanticString? nullSemanticString = null; char[] result = SemanticString.ToCharArray(nullSemanticString); - Assert.AreEqual(0, result.Length); + Assert.IsEmpty(result); } [TestMethod] @@ -329,7 +329,7 @@ public void ImplicitConversions_WithNull() ReadOnlySpan spanResult = nullSemanticString; Assert.AreEqual(string.Empty, stringResult); - Assert.AreEqual(0, charArrayResult.Length); + Assert.IsEmpty(charArrayResult); Assert.IsTrue(spanResult.IsEmpty); } @@ -1227,7 +1227,7 @@ public void StaticMethods_WithNullSemanticString_HandleGracefully() Assert.AreEqual(string.Empty, result); char[] charResult = SemanticString.ToCharArray(null); - Assert.AreEqual(0, charResult.Length); + Assert.IsEmpty(charResult); ReadOnlySpan spanResult = SemanticString.ToReadOnlySpan(null); Assert.IsTrue(spanResult.IsEmpty); diff --git a/Semantics.Test/Semantics.Test.csproj b/Semantics.Test/Semantics.Test.csproj index d367942..d75de80 100644 --- a/Semantics.Test/Semantics.Test.csproj +++ b/Semantics.Test/Semantics.Test.csproj @@ -9,12 +9,10 @@ true true true + $(NoWarn);MSTEST0032 - - -