diff --git a/.github/workflows/Format.yml b/.github/workflows/Format.yml index 3adcfc2..9c5b85b 100644 --- a/.github/workflows/Format.yml +++ b/.github/workflows/Format.yml @@ -46,7 +46,7 @@ jobs: if: ${{ needs.discover.result == 'success' }} uses: Stillpoint-Software/shared-workflows/.github/workflows/format.yml@main with: - dotnet_version: "9.0.x" + dotnet_version: "10.0.x" branch: ${{ needs.discover.outputs.branch_name }} secrets: inherit diff --git a/Directory.Build.props b/Directory.Build.props index 2b13e73..c2b3962 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ - + diff --git a/Hyperbee.Collections.sln b/Hyperbee.Collections.sln deleted file mode 100644 index 3995a05..0000000 --- a/Hyperbee.Collections.sln +++ /dev/null @@ -1,77 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31912.275 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{870D9301-BE3D-44EA-BF9C-FCC2E87FE4CD}" - ProjectSection(SolutionItems) = preProject - Directory.Build.props = Directory.Build.props - LICENSE = LICENSE - README.md = README.md - version.json = version.json - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Tests", "Solution Tests", "{F9B24CD9-E06B-4834-84CB-8C29E5F10BE0}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{1FA7CE2A-C9DA-4DC3-A242-5A7EAF8EE4FC}" - ProjectSection(SolutionItems) = preProject - .github\dependabot.yml = .github\dependabot.yml - .github\issue-branch.yml = .github\issue-branch.yml - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{4DBDB7F5-3F66-4572-80B5-3322449C77A4}" - ProjectSection(SolutionItems) = preProject - .github\workflows\create_release.yml = .github\workflows\create_release.yml - .github\workflows\create_test_report.yml = .github\workflows\create_test_report.yml - .github\workflows\deploy-gh-pages.yml = .github\workflows\deploy-gh-pages.yml - .github\workflows\format.yml = .github\workflows\format.yml - .github\workflows\issue_branch.yml = .github\workflows\issue_branch.yml - .github\workflows\pack_publish.yml = .github\workflows\pack_publish.yml - .github\workflows\run_tests.yml = .github\workflows\run_tests.yml - .github\workflows\unlist_package.yml = .github\workflows\unlist_package.yml - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbee.Collections", "src\Hyperbee.Collections\Hyperbee.Collections.csproj", "{574DD649-BC5B-40F5-92E5-BE6A289D4C92}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbee.Collections.Tests", "test\Hyperbee.Collections.Tests\Hyperbee.Collections.Tests.csproj", "{C75190AA-C837-4CB5-8C35-CF2F6DBA7BCF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbee.Collections.Benchmark", "test\Hyperbee.Collections.Benchmark\Hyperbee.Collections.Benchmark.csproj", "{970B058A-66CA-4157-B4DD-F79C89EBB9B4}" -EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "docs", "docs\docs.shproj", "{19842679-C717-4120-80E1-175AB4B15554}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {574DD649-BC5B-40F5-92E5-BE6A289D4C92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {574DD649-BC5B-40F5-92E5-BE6A289D4C92}.Debug|Any CPU.Build.0 = Debug|Any CPU - {574DD649-BC5B-40F5-92E5-BE6A289D4C92}.Release|Any CPU.ActiveCfg = Release|Any CPU - {574DD649-BC5B-40F5-92E5-BE6A289D4C92}.Release|Any CPU.Build.0 = Release|Any CPU - {C75190AA-C837-4CB5-8C35-CF2F6DBA7BCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C75190AA-C837-4CB5-8C35-CF2F6DBA7BCF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C75190AA-C837-4CB5-8C35-CF2F6DBA7BCF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C75190AA-C837-4CB5-8C35-CF2F6DBA7BCF}.Release|Any CPU.Build.0 = Release|Any CPU - {970B058A-66CA-4157-B4DD-F79C89EBB9B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {970B058A-66CA-4157-B4DD-F79C89EBB9B4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {970B058A-66CA-4157-B4DD-F79C89EBB9B4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {970B058A-66CA-4157-B4DD-F79C89EBB9B4}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {1FA7CE2A-C9DA-4DC3-A242-5A7EAF8EE4FC} = {870D9301-BE3D-44EA-BF9C-FCC2E87FE4CD} - {4DBDB7F5-3F66-4572-80B5-3322449C77A4} = {1FA7CE2A-C9DA-4DC3-A242-5A7EAF8EE4FC} - {C75190AA-C837-4CB5-8C35-CF2F6DBA7BCF} = {F9B24CD9-E06B-4834-84CB-8C29E5F10BE0} - {970B058A-66CA-4157-B4DD-F79C89EBB9B4} = {F9B24CD9-E06B-4834-84CB-8C29E5F10BE0} - {19842679-C717-4120-80E1-175AB4B15554} = {870D9301-BE3D-44EA-BF9C-FCC2E87FE4CD} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {32874F5B-B467-4F28-A8E2-82C2536FB228} - EndGlobalSection - GlobalSection(SharedMSBuildProjectFiles) = preSolution - docs\docs.projitems*{19842679-c717-4120-80e1-175ab4b15554}*SharedItemsImports = 13 - EndGlobalSection -EndGlobal diff --git a/Hyperbee.Collections.slnx b/Hyperbee.Collections.slnx new file mode 100644 index 0000000..597151d --- /dev/null +++ b/Hyperbee.Collections.slnx @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/README.md b/README.md index 81e13e8..ca421ec 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,11 @@ for more details. | `develop` | [![Build status](https://github.com/Stillpoint-Software/Hyperbee.Collections/actions/workflows/pack_publish.yml/badge.svg?branch=develop)](https://github.com/Stillpoint-Software/Hyperbee.Collections/actions/workflows/pack_publish.yml) | | `main` | [![Build status](https://github.com/Stillpoint-Software/Hyperbee.Collections/actions/workflows/pack_publish.yml/badge.svg)](https://github.com/Stillpoint-Software/Hyperbee.Collections/actions/workflows/pack_publish.yml) | + +# Benchmarks + See [Benchmarks](https://github.com/Stillpoint-Software/Hyperbee.Collections/test/Hyperbee.Collections.Benchmark/benchmark/results/Hyperbee.Collections.Benchmark.CollectionsBenchmark-report-github.md) + + # Help See [Todo](https://github.com/Stillpoint-Software/Hyperbee.Collections/blob/main/docs/todo.md) diff --git a/src/Hyperbee.Collections/Hyperbee.Collections.csproj b/src/Hyperbee.Collections/Hyperbee.Collections.csproj index f510eef..e4f17c6 100644 --- a/src/Hyperbee.Collections/Hyperbee.Collections.csproj +++ b/src/Hyperbee.Collections/Hyperbee.Collections.csproj @@ -1,6 +1,6 @@  - net8.0;net9.0 + net8.0;net10.0 enable disable true @@ -33,10 +33,13 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive + + \ No newline at end of file diff --git a/test/Hyperbee.Collections.Benchmark/BenchmarkConfig.cs b/test/Hyperbee.Collections.Benchmark/BenchmarkConfig.cs index b2a5c3a..06c1df5 100644 --- a/test/Hyperbee.Collections.Benchmark/BenchmarkConfig.cs +++ b/test/Hyperbee.Collections.Benchmark/BenchmarkConfig.cs @@ -8,6 +8,7 @@ using BenchmarkDotNet.Validators; namespace Hyperbee.Collections.Benchmark; + public class BenchmarkConfig { public class Config : ManualConfig diff --git a/test/Hyperbee.Collections.Benchmark/CollectionsBenchmark.cs b/test/Hyperbee.Collections.Benchmark/CollectionsBenchmark.cs index 613aa1f..630d6b8 100644 --- a/test/Hyperbee.Collections.Benchmark/CollectionsBenchmark.cs +++ b/test/Hyperbee.Collections.Benchmark/CollectionsBenchmark.cs @@ -4,6 +4,7 @@ #pragma warning disable CA1806 namespace Hyperbee.Collections.Benchmark; + public class CollectionsBenchmark { private const char Separator = ','; diff --git a/test/Hyperbee.Collections.Benchmark/Hyperbee.Collections.Benchmark.csproj b/test/Hyperbee.Collections.Benchmark/Hyperbee.Collections.Benchmark.csproj index ef161f0..162a512 100644 --- a/test/Hyperbee.Collections.Benchmark/Hyperbee.Collections.Benchmark.csproj +++ b/test/Hyperbee.Collections.Benchmark/Hyperbee.Collections.Benchmark.csproj @@ -2,17 +2,22 @@ Exe - net9.0 + net10.0 enable false - + + + + + + diff --git a/test/Hyperbee.Collections.Benchmark/benchmark/results/Hyperbee.Collections.Benchmark.CollectionsBenchmark-report-github.md b/test/Hyperbee.Collections.Benchmark/benchmark/results/Hyperbee.Collections.Benchmark.CollectionsBenchmark-report-github.md index b647b57..ae9c87c 100644 --- a/test/Hyperbee.Collections.Benchmark/benchmark/results/Hyperbee.Collections.Benchmark.CollectionsBenchmark-report-github.md +++ b/test/Hyperbee.Collections.Benchmark/benchmark/results/Hyperbee.Collections.Benchmark.CollectionsBenchmark-report-github.md @@ -1,10 +1,10 @@ ``` -BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.2033) -12th Gen Intel Core i9-12900HK, 1 CPU, 20 logical and 14 physical cores -.NET SDK 9.0.100 - [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 DEBUG - ShortRun : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 +BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.7462/25H2/2025Update/HudsonValley2) +12th Gen Intel Core i9-12900HK 2.50GHz, 1 CPU, 20 logical and 14 physical cores +.NET SDK 10.0.101 + [Host] : .NET 10.0.1 (10.0.1, 10.0.125.57005), X64 RyuJIT x86-64-v3 DEBUG + ShortRun : .NET 10.0.1 (10.0.1, 10.0.125.57005), X64 RyuJIT x86-64-v3 Job=ShortRun IterationCount=3 LaunchCount=1 WarmupCount=3 @@ -12,5 +12,5 @@ WarmupCount=3 ``` | Method | List | Mean | Error | StdDev | Gen0 | Gen1 | Allocated | |------------------------- |---------------- |---------:|----------:|----------:|-------:|-------:|----------:| -| LinkedDirectorySelectAll | aa1,bb1,cc1,dd1 | 1.990 μs | 0.6392 μs | 0.0350 μs | 0.4425 | 0.0038 | 5.45 KB | -| LinkedDirectorySelectAll | aa2,bb2,cc2,dd2 | 2.061 μs | 1.0472 μs | 0.0574 μs | 0.4425 | 0.0038 | 5.45 KB | +| LinkedDirectorySelectAll | aa2,bb2,cc2,dd2 | 1.781 μs | 0.2390 μs | 0.0131 μs | 0.4444 | 0.0038 | 5.46 KB | +| LinkedDirectorySelectAll | aa1,bb1,cc1,dd1 | 1.880 μs | 0.7184 μs | 0.0394 μs | 0.4444 | 0.0038 | 5.46 KB | diff --git a/test/Hyperbee.Collections.Tests/AhoCorasickTests.cs b/test/Hyperbee.Collections.Tests/AhoCorasickTests.cs index 5122333..e78f5aa 100644 --- a/test/Hyperbee.Collections.Tests/AhoCorasickTests.cs +++ b/test/Hyperbee.Collections.Tests/AhoCorasickTests.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Hyperbee.Collections.Tests; +namespace Hyperbee.Collections.Tests; [TestClass] public class AhoCorasickTests @@ -24,7 +19,7 @@ public void Should_find_entries() var matches = trie.Find( haystack ).ToArray(); - Assert.AreEqual( 9, matches.Length ); + Assert.HasCount( 9, matches ); Assert.IsTrue( "all" == Match( matches[0], haystack ) && 0 == matches[0].Index ); Assert.IsTrue( "base" == Match( matches[1], haystack ) && 11 == matches[1].Index ); @@ -51,7 +46,7 @@ public void Should_find_selected_entries() var matches = trie.Find( haystack ).Where( x => x.Overlap == 0 ).ToArray(); - Assert.AreEqual( 4, matches.Length ); + Assert.HasCount( 4, matches ); Assert.IsTrue( "all" == Match( matches[0], haystack ) && 0 == matches[0].Index ); Assert.IsTrue( "bbaselless" == Match( matches[1], haystack ) && 10 == matches[1].Index ); @@ -82,7 +77,7 @@ public void Should_find_selected1_entries() } ) .ToArray(); - Assert.AreEqual( 3, matches.Length ); + Assert.HasCount( 3, matches ); Assert.IsTrue( Match( matches[0], haystack ) == "Base" && "key_base" == matches[0].Tag && 9 == matches[0].Index ); Assert.IsTrue( Match( matches[1], haystack ) == "tent" && "key_tent" == matches[1].Tag && 41 == matches[1].Index ); @@ -99,7 +94,7 @@ public void Should_find_caseinsensistive_entries() var matches = trie.Find( haystack ).ToArray(); - Assert.AreEqual( 2, matches.Length ); + Assert.HasCount( 2, matches ); } [TestMethod] @@ -116,7 +111,7 @@ public void Should_return_associated_value() var matches = trie.Find( haystack ); var lines = matches.Select( x => x.Tag ).ToArray(); - Assert.AreEqual( 2, lines.Length ); + Assert.HasCount( 2, lines ); Assert.AreEqual( 1, lines[0] ); Assert.AreEqual( 0, lines[1] ); } @@ -145,7 +140,7 @@ public void Should_return_projected_value() } ) .ToArray(); - Assert.AreEqual( 2, matches.Length ); + Assert.HasCount( 2, matches ); Assert.AreEqual( "base", matches[0].Word ); Assert.AreEqual( guid1, matches[0].GuidTag ); Assert.AreEqual( guidRef, matches[1].GuidRef ); diff --git a/test/Hyperbee.Collections.Tests/ArrayPool/PooledArrayTests.cs b/test/Hyperbee.Collections.Tests/ArrayPool/PooledArrayTests.cs index df18bf1..f13395a 100644 --- a/test/Hyperbee.Collections.Tests/ArrayPool/PooledArrayTests.cs +++ b/test/Hyperbee.Collections.Tests/ArrayPool/PooledArrayTests.cs @@ -27,7 +27,17 @@ public void Indexer_ShouldThrow_WhenOutOfRange() using var array = new PooledArray(); // Act & Assert - Assert.ThrowsException( () => _ = array[0] ); + var exception = false; + try + { + _ = array[0]; + } + catch ( ArgumentOutOfRangeException ) + { + exception = true; + } + + Assert.IsTrue( exception, "Expected ArgumentOutOfRangeException was not thrown" ); } [TestMethod] @@ -58,7 +68,17 @@ public void Dispose_ShouldReleaseMemory() array.Dispose(); // Assert - Assert.ThrowsException( () => array.Add( 1 ) ); + var exception = false; + try + { + array.Add( 1 ); + } + catch ( ObjectDisposedException ) + { + exception = true; + } + + Assert.IsTrue( exception, "Expected ObjectDisposedException was not thrown" ); } [TestMethod] diff --git a/test/Hyperbee.Collections.Tests/ArrayPool/PooledStackTests.cs b/test/Hyperbee.Collections.Tests/ArrayPool/PooledStackTests.cs index 1cfdf8b..e631a4b 100644 --- a/test/Hyperbee.Collections.Tests/ArrayPool/PooledStackTests.cs +++ b/test/Hyperbee.Collections.Tests/ArrayPool/PooledStackTests.cs @@ -42,7 +42,17 @@ public void Pop_ShouldThrow_WhenStackIsEmpty() using var stack = new PooledStack(); // Act & Assert - Assert.ThrowsException( () => stack.Pop() ); + var exception = false; + try + { + stack.Pop(); + } + catch ( InvalidOperationException ) + { + exception = true; + } + + Assert.IsTrue( exception, "Expected InvalidOperationException was not thrown" ); } [TestMethod] @@ -86,6 +96,16 @@ public void Dispose_ShouldReleaseMemory() stack.Dispose(); // Assert - Assert.ThrowsException( () => stack.Push( 1 ) ); + var exception = false; + try + { + stack.Push( 1 ); + } + catch ( ObjectDisposedException ) + { + exception = true; + } + + Assert.IsTrue( exception, "Expected ObjectDisposedException was not thrown" ); } } diff --git a/test/Hyperbee.Collections.Tests/DequeueTests.cs b/test/Hyperbee.Collections.Tests/DequeueTests.cs index 3b02dff..1e02295 100644 --- a/test/Hyperbee.Collections.Tests/DequeueTests.cs +++ b/test/Hyperbee.Collections.Tests/DequeueTests.cs @@ -1,5 +1,4 @@ using System.Numerics; -using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Hyperbee.Collections.Tests; @@ -15,7 +14,7 @@ public void Constructor_should_create_empty_queue() Assert.IsTrue( deque.IsEmpty ); } - [DataTestMethod] + [TestMethod] [DataRow( "aa,bb,cc,dd", "aa,bb,cc,dd" )] public void Constructor_should_initialize_with_collection( string input, string output ) { @@ -42,7 +41,7 @@ public void Constructor_should_set_capacity() Assert.AreEqual( (int) BitOperations.RoundUpToPowerOf2( (uint) collection.Length ), deque.Capacity ); } - [DataTestMethod] + [TestMethod] [DataRow( "aa,bb,cc,dd", "xx", 1, "aa,xx,bb,cc,dd" )] // test InsertRange first half insert [DataRow( "aa,bb,cc,dd", "xx,yy", 1, "aa,xx,yy,bb,cc,dd" )] @@ -61,7 +60,7 @@ public void Should_insert_range( string input, string insert, int index, string CollectionAssert.AreEqual( expected, result ); } - [DataTestMethod] + [TestMethod] [DataRow( "aa,bb,cc,dd", "xx,yy,zz", 1, 0, -1, "aa,xx,yy,zz,bb,cc,dd" )] [DataRow( "aa,bb,cc,dd", "xx,yy,zz", 1, 0, 0, "aa,bb,cc,dd" )] [DataRow( "aa,bb,cc,dd", "xx,yy,zz", 1, 1, -1, "aa,yy,zz,bb,cc,dd" )] @@ -83,7 +82,7 @@ public void Should_insert_range_scoped( string input, string insert, int index, CollectionAssert.AreEqual( expected, result ); } - [DataTestMethod] + [TestMethod] [DataRow( "aa,bb,cc,dd,ee", "xx", false )] [DataRow( "aa,bb,cc,dd,ee", "ee", true )] public void Contains_should_return_correct_result( string input, string value, bool expected ) @@ -92,7 +91,7 @@ public void Contains_should_return_correct_result( string input, string value, b var deque = new Deque( collection ); var result = deque.Contains( value ); - Assert.IsTrue( result == expected ); + Assert.AreEqual( expected, result ); } [TestMethod] @@ -125,7 +124,7 @@ public void Should_add_last() deque.AddLast( expected ); - Assert.IsTrue( deque.Count == 2 ); + Assert.AreEqual( 2, deque.Count ); Assert.IsTrue( deque.Contains( expected ) ); var result = deque[1]; @@ -145,7 +144,7 @@ public void Should_add_front() deque.AddFirst( expected ); - Assert.IsTrue( deque.Count == 2 ); + Assert.AreEqual( 2, deque.Count ); Assert.IsTrue( deque.Contains( expected ) ); var result = deque[0]; diff --git a/test/Hyperbee.Collections.Tests/DisjointSetTests.cs b/test/Hyperbee.Collections.Tests/DisjointSetTests.cs index 6890d84..6e86c09 100644 --- a/test/Hyperbee.Collections.Tests/DisjointSetTests.cs +++ b/test/Hyperbee.Collections.Tests/DisjointSetTests.cs @@ -1,4 +1,6 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Hyperbee.Collections.Tests; @@ -101,14 +103,23 @@ public void FindGroup_ShouldReturnAllItemsInSameGroup() } [TestMethod] - [ExpectedException( typeof( InvalidOperationException ) )] public void Find_NonExistentItem_ShouldThrowException() { // Arrange var disjointSet = new DisjointSet(); - // Act - disjointSet.Find( 1 ); + // Act & Assert + var exception = false; + try + { + disjointSet.Find( 1 ); + } + catch ( InvalidOperationException ) + { + exception = true; + } + + Assert.IsTrue( exception, "Expected InvalidOperationException was not thrown" ); } [TestMethod] diff --git a/test/Hyperbee.Collections.Tests/Extensions/IEnumerableExtensionsTests.cs b/test/Hyperbee.Collections.Tests/Extensions/IEnumerableExtensionsTests.cs index 1e421ae..8520f7d 100644 --- a/test/Hyperbee.Collections.Tests/Extensions/IEnumerableExtensionsTests.cs +++ b/test/Hyperbee.Collections.Tests/Extensions/IEnumerableExtensionsTests.cs @@ -1,6 +1,5 @@ using System.Collections.Concurrent; using Hyperbee.Collections.Extensions; -using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Hyperbee.Collections.Tests.Extensions; @@ -47,23 +46,41 @@ await emptyData.ParallelEachAsync( async item => } ); // Assert - Assert.AreEqual( 0, processedItems.Count, "No items should be processed for an empty collection." ); + Assert.IsEmpty( processedItems, "No items should be processed for an empty collection." ); } [TestMethod] public async Task ParallelEachAsync_ShouldThrowArgumentNullException_ForNullSource() { // Act & Assert - await Assert.ThrowsExceptionAsync( () => - ((IEnumerable) null).ParallelEachAsync( async item => await Task.Yield() ) ); + var exception = false; + try + { + await ((IEnumerable) null).ParallelEachAsync( async item => await Task.Yield() ); + } + catch ( ArgumentNullException ) + { + exception = true; + } + + Assert.IsTrue( exception, "Expected ArgumentNullException was not thrown" ); } [TestMethod] public async Task ParallelEachAsyncc_ShouldThrowArgumentNullException_ForNullDelegate() { // Act & Assert - await Assert.ThrowsExceptionAsync( () => - _testData.ParallelEachAsync( null ) ); + var exception = false; + try + { + await _testData.ParallelEachAsync( null ); + } + catch ( ArgumentNullException ) + { + exception = true; + } + + Assert.IsTrue( exception, "Expected ArgumentNullException was not thrown" ); } [TestMethod] @@ -89,7 +106,7 @@ await _testData.ParallelEachAsync( async item => } // Assert - Assert.IsTrue( processedItems.Count < _testData.Count, "Not all items should be processed after cancellation." ); + Assert.IsLessThan( _testData.Count, processedItems.Count, "Not all items should be processed after cancellation." ); } [TestMethod] diff --git a/test/Hyperbee.Collections.Tests/Hyperbee.Collections.Tests.csproj b/test/Hyperbee.Collections.Tests/Hyperbee.Collections.Tests.csproj index 60d7368..dd38649 100644 --- a/test/Hyperbee.Collections.Tests/Hyperbee.Collections.Tests.csproj +++ b/test/Hyperbee.Collections.Tests/Hyperbee.Collections.Tests.csproj @@ -1,6 +1,6 @@  - net8.0;net9.0 + net8.0;net10.0 enable disable false @@ -12,17 +12,19 @@ - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive + \ No newline at end of file diff --git a/test/Hyperbee.Collections.Tests/LinkedDictionaryTests.cs b/test/Hyperbee.Collections.Tests/LinkedDictionaryTests.cs index 7c2dc26..4d0261a 100644 --- a/test/Hyperbee.Collections.Tests/LinkedDictionaryTests.cs +++ b/test/Hyperbee.Collections.Tests/LinkedDictionaryTests.cs @@ -1,5 +1,4 @@ using Hyperbee.Collections.Extensions; -using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Hyperbee.Collections.Tests; @@ -8,7 +7,7 @@ public class LinkedDictionaryTests { private const char Separator = ','; - [DataTestMethod] + [TestMethod] [DataRow( "aa1,bb1,cc1,dd1", "aa2,bb2,cc2,dd2", "0:aa2,0:bb2,0:cc2,0:dd2,1:aa1,1:bb1,1:cc1,1:dd1" )] public void Should_select_all( string input1, string input2, string output ) { @@ -26,7 +25,7 @@ public void Should_select_all( string input1, string input2, string output ) CollectionAssert.AreEquivalent( expected, result ); } - [DataTestMethod] + [TestMethod] [DataRow( "aa,bb,cc,dd", "aa,dd,ee", "0:aa,0:dd,0:ee" )] public void Should_select_current( string input1, string input2, string output ) { @@ -44,7 +43,7 @@ public void Should_select_current( string input1, string input2, string output ) CollectionAssert.AreEquivalent( expected, result ); } - [DataTestMethod] + [TestMethod] [DataRow( "aa,bb,cc,dd", "aa,dd,ee", "0:aa,0:dd,0:ee,1:bb,1:cc" )] public void Should_select_single( string input1, string input2, string output ) { @@ -62,7 +61,7 @@ public void Should_select_single( string input1, string input2, string output ) CollectionAssert.AreEquivalent( expected, result ); } - [DataTestMethod] + [TestMethod] [DataRow( "aa,bb,cc,dd", "aa,dd,ee", "0:aa,0:dd,0:ee" )] public void Should_add_current( string input1, string input2, string output ) { @@ -86,7 +85,7 @@ public void Should_add_current( string input1, string input2, string output ) CollectionAssert.AreEquivalent( expected, result ); } - [DataTestMethod] + [TestMethod] [DataRow( "aa,bb,cc,dd", "ee", "0:ee,1:aa,1:bb,1:cc,1:dd" )] public void Should_add_single( string input1, string input2, string output ) { @@ -110,9 +109,8 @@ public void Should_add_single( string input1, string input2, string output ) CollectionAssert.AreEquivalent( expected, result ); } - [DataTestMethod] + [TestMethod] [DataRow( "aa,bb,cc,dd", "bb" )] - [ExpectedException( typeof( ArgumentException ), "Key already exists." )] public void Should_add_single_with_same_key( string input1, string input2 ) { var d1 = CreateDictionary( input1 ); @@ -123,14 +121,25 @@ public void Should_add_single_with_same_key( string input1, string input2 ) ld.Push( d1 ); ld.Push(); // empty new scope - // manually add values - foreach ( var pair in d2 ) + // Act & Assert + var exception = false; + try { - ld.Add( LinkedNode.Single, pair.Key, pair.Value ); + // manually add values + foreach ( var pair in d2 ) + { + ld.Add( LinkedNode.Single, pair.Key, pair.Value ); + } + } + catch ( ArgumentException ) + { + exception = true; } + + Assert.IsTrue( exception, "Expected ArgumentException was not thrown" ); } - [DataTestMethod] + [TestMethod] [DataRow( "aa,bb,cc,dd", "aa,dd,ee", "0:aa,0:dd,0:ee,1:aa,1:bb,1:cc,1:dd" )] public void Should_add_all( string input1, string input2, string output ) { @@ -161,7 +170,7 @@ public void Should_clear_without_exception_when_empty() ld.Clear(); } - [DataTestMethod] + [TestMethod] [DataRow( "aa,bb,cc,dd", "aa,dd,ee" )] public void Should_clear_all_items( string input1, string input2 ) { @@ -178,7 +187,7 @@ public void Should_clear_all_items( string input1, string input2 ) Assert.AreEqual( 0, ld.Count ); } - [DataTestMethod] + [TestMethod] [DataRow( "aa,bb,cc,dd", "aa,dd,ee", "1:aa,1:bb,1:cc,1:dd" )] public void Should_clear_current_node( string input1, string input2, string output ) {