From a46ec974438ada6214d9e2dce763074d6b7057ee Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 13 Nov 2024 18:10:57 +0000 Subject: [PATCH 1/6] chore: add net9.0 target --- .github/workflows/dotnet.yml | 1 + .github/workflows/nightly.yml | 2 +- .github/workflows/prerelease.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/source_validator.yml | 2 +- X10D.Hosting/X10D.Hosting.csproj | 2 +- X10D.Tests/X10D.Tests.csproj | 2 +- X10D/X10D.csproj | 2 +- global.json | 2 +- 9 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 8558da217..a533cf842 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -24,6 +24,7 @@ jobs: with: dotnet-version: | 8.0.x + 9.0.x - name: Add NuGet source run: dotnet nuget add source --username oliverbooth --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/oliverbooth/index.json" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4ca325512..2739e8363 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -18,7 +18,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Add GitHub NuGet source run: dotnet nuget add source --username oliverbooth --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/oliverbooth/index.json" diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 94cb5043f..01deb82ec 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -17,7 +17,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Add GitHub NuGet source run: dotnet nuget add source --username oliverbooth --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/oliverbooth/index.json" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a4523035e..8c99c4900 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Add GitHub NuGet source run: dotnet nuget add source --username oliverbooth --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/oliverbooth/index.json" diff --git a/.github/workflows/source_validator.yml b/.github/workflows/source_validator.yml index a1024c595..d782e63d3 100644 --- a/.github/workflows/source_validator.yml +++ b/.github/workflows/source_validator.yml @@ -19,7 +19,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Add GitHub NuGet source run: dotnet nuget add source --username oliverbooth --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/oliverbooth/index.json" diff --git a/X10D.Hosting/X10D.Hosting.csproj b/X10D.Hosting/X10D.Hosting.csproj index 74d07d378..09c069d9a 100644 --- a/X10D.Hosting/X10D.Hosting.csproj +++ b/X10D.Hosting/X10D.Hosting.csproj @@ -1,7 +1,7 @@ - net8.0 + net8.0;net9.0 diff --git a/X10D.Tests/X10D.Tests.csproj b/X10D.Tests/X10D.Tests.csproj index 74bdbc1c0..0184a2b26 100644 --- a/X10D.Tests/X10D.Tests.csproj +++ b/X10D.Tests/X10D.Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net8.0;net9.0 false true xml,cobertura diff --git a/X10D/X10D.csproj b/X10D/X10D.csproj index 3961f9595..cb6b70a5a 100644 --- a/X10D/X10D.csproj +++ b/X10D/X10D.csproj @@ -1,7 +1,7 @@ - net8.0 + net8.0;net9.0 diff --git a/global.json b/global.json index b5b37b60d..a27a2b823 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.0", + "version": "9.0.0", "rollForward": "latestMajor", "allowPrerelease": false } From b3dfaa727e596206e574bcdb20c2c1acb7b7259e Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 13 Nov 2024 18:12:44 +0000 Subject: [PATCH 2/6] ci: bump actions/setup-dotnet to v4 --- .github/workflows/dotnet.yml | 2 +- .github/workflows/nightly.yml | 2 +- .github/workflows/prerelease.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/source_validator.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index a533cf842..1756f8cbe 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: | 8.0.x diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2739e8363..d8c39e586 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: 9.0.x diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 01deb82ec..8bd5742f2 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: 9.0.x diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8c99c4900..b72d4a666 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: 9.0.x diff --git a/.github/workflows/source_validator.yml b/.github/workflows/source_validator.yml index d782e63d3..6a9e072a6 100644 --- a/.github/workflows/source_validator.yml +++ b/.github/workflows/source_validator.yml @@ -17,7 +17,7 @@ jobs: uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: 9.0.x From 9d870b2c241bd521e38c89f8a40bd971f308c52b Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 13 Nov 2024 18:15:24 +0000 Subject: [PATCH 3/6] chore(test): update dependencies * coverlet.collector 6.0.2 * Microsoft.Extensions.Hosting 9.0.0 * Microsoft.NET.Test.Sdk 17.11.1 * NSubstitute 5.3.0 * NUnit 4.2.2 * NUnit3TestAdapter 4.6.0 * NUnit.Analyzers 4.3.0 * System.Reactive 6.0.1 --- X10D.Tests/X10D.Tests.csproj | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/X10D.Tests/X10D.Tests.csproj b/X10D.Tests/X10D.Tests.csproj index 0184a2b26..8092409c2 100644 --- a/X10D.Tests/X10D.Tests.csproj +++ b/X10D.Tests/X10D.Tests.csproj @@ -14,14 +14,14 @@ - - - - - - - - + + + + + + + + From 0b978f5cdfb717c175887a52ba2102018ff0b411 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 13 Nov 2024 18:22:36 +0000 Subject: [PATCH 4/6] refactor!: remove Span.Split --- CHANGELOG.md | 12 ++++++++++-- X10D.Tests/src/Collections/SpanTest.cs | 4 ++++ X10D/src/Collections/SpanExtensions.cs | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29a70fabb..521a00edd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 4.0.0 - [Unreleased] +## 4.0.1 - [Unreleased] + +### Removed + +- X10D: Removed `Span.Split` for .NET 9.0 target due to conflicts with +[`System.MemoryExtensions.Split`](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.split?view=net-8.0). + +## [4.0.0] - 2024-06-12 ### Added @@ -642,7 +649,8 @@ please [open an issue](https://github.com/oliverbooth/X10D/issues)! Earlier versions of this package are undocumented and unlisted from package results. -[unreleased]: https://github.com/oliverbooth/X10D/compare/v3.3.1...main +[unreleased]: https://github.com/oliverbooth/X10D/compare/v4.0.0...main +[4.0.0]: https://github.com/oliverbooth/X10D/releases/tag/v4.0.0 [3.3.1]: https://github.com/oliverbooth/X10D/releases/tag/v3.3.1 [3.3.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.3.0 [3.2.2]: https://github.com/oliverbooth/X10D/releases/tag/v3.2.2 diff --git a/X10D.Tests/src/Collections/SpanTest.cs b/X10D.Tests/src/Collections/SpanTest.cs index fa7ac4580..114336e97 100644 --- a/X10D.Tests/src/Collections/SpanTest.cs +++ b/X10D.Tests/src/Collections/SpanTest.cs @@ -1,5 +1,7 @@ using NUnit.Framework; +#if !NET9_0_OR_GREATER using X10D.Collections; +#endif namespace X10D.Tests.Collections; @@ -70,6 +72,7 @@ public void Replace_ShouldDoNothing_GivenSpanWithNoMatchingElements() Assert.That(span.ToArray(), Is.EqualTo(new[] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2})); } +#if !NET9_0_OR_GREATER [Test] public void Split_OnEmptySpan_ShouldYieldNothing_UsingCharDelimiter_GivenReadOnlySpan() { @@ -497,4 +500,5 @@ public void Split_OnThreeWords_ShouldYieldLength3_UsingStringDelimiter_GivenSpan Assert.That(index, Is.EqualTo(3)); } +#endif } diff --git a/X10D/src/Collections/SpanExtensions.cs b/X10D/src/Collections/SpanExtensions.cs index 7c3ee0a4a..d063dd9bd 100644 --- a/X10D/src/Collections/SpanExtensions.cs +++ b/X10D/src/Collections/SpanExtensions.cs @@ -75,6 +75,7 @@ public static void Replace(this Span haystack, T needle, T replacement) wh } #endif +#if !NET9_0_OR_GREATER /// /// Splits a span of elements into sub-spans based on a delimiting element. /// @@ -134,4 +135,5 @@ public static SpanSplitEnumerator Split(this in ReadOnlySpan source, in { return new SpanSplitEnumerator(source, delimiter); } +#endif } From a433244799efaf9e08f430a3d86da60c3d6052c4 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 13 Nov 2024 18:41:45 +0000 Subject: [PATCH 5/6] fix(test): use new NUnit constraint API --- X10D.Tests/src/Collections/EnumerableTests.cs | 16 ++-- X10D.Tests/src/Collections/ListTests.cs | 64 ++++++------- X10D.Tests/src/Collections/SpanTest.cs | 16 ++-- X10D.Tests/src/Core/CoreTests.cs | 2 +- X10D.Tests/src/Core/SpanTest.cs | 1 - X10D.Tests/src/Drawing/PolygonFTests.cs | 6 +- X10D.Tests/src/Drawing/PolyhedronTests.cs | 10 +- .../src/Hosting/ServiceCollectionTests.cs | 16 ++-- X10D.Tests/src/IO/BooleanTests.cs | 4 +- X10D.Tests/src/IO/ByteTests.cs | 11 ++- X10D.Tests/src/IO/DecimalTests.cs | 24 +++-- X10D.Tests/src/IO/DoubleTests.cs | 22 +++-- X10D.Tests/src/IO/FileInfoTests.cs | 14 ++- X10D.Tests/src/IO/Int16Tests.cs | 22 +++-- X10D.Tests/src/IO/Int32Tests.cs | 22 +++-- X10D.Tests/src/IO/Int64Tests.cs | 22 +++-- X10D.Tests/src/IO/SByteTests.cs | 11 ++- X10D.Tests/src/IO/SingleTests.cs | 22 +++-- X10D.Tests/src/IO/StreamTests.WriteDecimal.cs | 38 ++++---- X10D.Tests/src/IO/StreamTests.WriteDouble.cs | 26 ++++-- X10D.Tests/src/IO/StreamTests.WriteInt16.cs | 26 ++++-- X10D.Tests/src/IO/StreamTests.WriteInt32.cs | 26 ++++-- X10D.Tests/src/IO/StreamTests.WriteInt64.cs | 26 ++++-- X10D.Tests/src/IO/StreamTests.WriteSingle.cs | 26 ++++-- X10D.Tests/src/IO/StreamTests.WriteUInt16.cs | 26 ++++-- X10D.Tests/src/IO/StreamTests.WriteUInt32.cs | 26 ++++-- X10D.Tests/src/IO/StreamTests.WriteUInt64.cs | 26 ++++-- X10D.Tests/src/IO/StreamTests.cs | 4 +- X10D.Tests/src/IO/UInt16Tests.cs | 24 +++-- X10D.Tests/src/IO/UInt32Tests.cs | 24 +++-- X10D.Tests/src/IO/UInt64Tests.cs | 24 +++-- X10D.Tests/src/Math/IsPrimeTests.cs | 2 +- X10D.Tests/src/Text/CoreTests.cs | 8 +- X10D.Tests/src/Text/EnumerableTests.cs | 32 ++++--- .../src/Text/StringBuilderReaderTests.cs | 91 ++++++++++++------- X10D.Tests/src/Text/StringTests.cs | 9 +- 36 files changed, 457 insertions(+), 312 deletions(-) diff --git a/X10D.Tests/src/Collections/EnumerableTests.cs b/X10D.Tests/src/Collections/EnumerableTests.cs index a08c05fda..37e19f8c0 100644 --- a/X10D.Tests/src/Collections/EnumerableTests.cs +++ b/X10D.Tests/src/Collections/EnumerableTests.cs @@ -117,11 +117,11 @@ public void For_ShouldTransform_GivenTransformationDelegate() IEnumerable source = oneToTen.Select(i => new DummyClass {Value = i}).ToArray(); IEnumerable values = source.Select(o => o.Value); - CollectionAssert.AreEqual(oneToTen, values.ToArray()); + Assert.That(values.ToArray(), Is.EqualTo(oneToTen).AsCollection); source.For((i, o) => o.Value *= i); values = source.Select(o => o.Value); - CollectionAssert.AreEqual(multipliedByIndex, values.ToArray()); + Assert.That(values.ToArray(), Is.EqualTo(multipliedByIndex).AsCollection); } [Test] @@ -146,11 +146,11 @@ public void ForEach_ShouldTransform_GivenTransformationDelegate() IEnumerable source = oneToTen.Select(i => new DummyClass {Value = i}).ToArray(); IEnumerable values = source.Select(o => o.Value); - CollectionAssert.AreEqual(oneToTen, values.ToArray()); + Assert.That(values.ToArray(), Is.EqualTo(oneToTen).AsCollection); source.ForEach(o => o.Value *= 2); values = source.Select(o => o.Value); - CollectionAssert.AreEqual(oneToTenDoubled, values.ToArray()); + Assert.That(values.ToArray(), Is.EqualTo(oneToTenDoubled).AsCollection); } [Test] @@ -245,10 +245,10 @@ public void Shuffled_ShouldReorder_GivenNotNull() int[] array = Enumerable.Range(1, 52).ToArray(); // 52! chance of being shuffled to the same order int[] shuffled = array[..]; - CollectionAssert.AreEqual(array, shuffled); + Assert.That(shuffled, Is.EqualTo(array).AsCollection); shuffled = array.Shuffled().ToArray(); - CollectionAssert.AreNotEqual(array, shuffled); + Assert.That(shuffled, Is.Not.EqualTo(array).AsCollection); } [Test] @@ -256,7 +256,7 @@ public void WhereNot_ShouldReturnCorrectElements_GivenSequence() { var enumerable = new[] {2, 4, 6, 7, 8, 9, 10}; IEnumerable result = enumerable.WhereNot(x => x % 2 == 0); - CollectionAssert.AreEqual(new[] {7, 9}, result.ToArray()); + Assert.That(result.ToArray(), Is.EqualTo(new[] { 7, 9 }).AsCollection); } [Test] @@ -285,7 +285,7 @@ public void WhereNotNull_ShouldContainNoNullElements() foreach (object o in array.WhereNotNull()) { - Assert.IsNotNull(o); + Assert.That(o, Is.Not.Null); actualCount++; } diff --git a/X10D.Tests/src/Collections/ListTests.cs b/X10D.Tests/src/Collections/ListTests.cs index a2f7f280a..469d097f8 100644 --- a/X10D.Tests/src/Collections/ListTests.cs +++ b/X10D.Tests/src/Collections/ListTests.cs @@ -6,7 +6,7 @@ namespace X10D.Tests.Collections; [TestFixture] internal class ListTests { - [Test] + [Test] [TestCase(1)] [TestCase(1, 2, 3)] [TestCase(1, 2, 3, 4, 5)] @@ -15,17 +15,17 @@ public void Fill_ShouldGiveHomogenousList_GivenValue(params int[] args) int[] all42 = Enumerable.Repeat(42, args.Length).ToArray(); var list = new List(args); - CollectionAssert.AreEqual(args, list); + Assert.That(list, Is.EqualTo(args).AsCollection); args.Fill(42); list.Fill(42); - CollectionAssert.AreEqual(args, list); - CollectionAssert.AreEqual(all42, args); - CollectionAssert.AreEqual(all42, list); + Assert.That(list, Is.EqualTo(args).AsCollection); + Assert.That(args, Is.EqualTo(all42).AsCollection); + Assert.That(list, Is.EqualTo(all42).AsCollection); } - [Test] + [Test] [TestCase(1)] [TestCase(1, 2, 3)] [TestCase(1, 2, 3, 4, 5)] @@ -36,7 +36,7 @@ public void SlicedFill_ShouldLeaveFirstElement_GivenStartIndex1(params int[] arg int[] comparison = Enumerable.Repeat(1, args.Length - 1).ToArray(); Assert.That(args[0], Is.EqualTo(first)); - CollectionAssert.AreEqual(comparison, args[1..]); + Assert.That(args[1..], Is.EqualTo(comparison).AsCollection); } [Test] @@ -80,7 +80,7 @@ public void Fill_ShouldThrow_GivenNull() [Test] public void IndexOf_ShouldReturnCorrectValue_FromStartOfList() { - int[] array = {0, 1, 2, 3, 4}; + int[] array = { 0, 1, 2, 3, 4 }; Assert.Multiple(() => { Assert.That(array.IndexOf(2), Is.EqualTo(2)); @@ -92,7 +92,7 @@ public void IndexOf_ShouldReturnCorrectValue_FromStartOfList() [Test] public void IndexOf_ShouldReturnCorrectValue_GivenSubRange() { - int[] array = {0, 1, 2, 3, 4, 0}; + int[] array = { 0, 1, 2, 3, 4, 0 }; Assert.Multiple(() => { Assert.That(array.IndexOf(0), Is.Zero); @@ -149,7 +149,7 @@ public void IndexOf_ShouldThrowArgumentOutOfRangeException_GivenNegativeStartInd [Test] public void IndexOf_ShouldThrowArgumentOutOfRangeException_GivenInvalidStartIndexCountPair() { - int[] array = {0, 1, 2}; + int[] array = { 0, 1, 2 }; Assert.Throws(() => array.IndexOf(0, 2, 4)); } @@ -184,7 +184,7 @@ public void RemoveRange_ShouldThrowArgumentOutOfRangeException_GivenEndIndexLess public void RemoveRange_ShouldThrowArgumentOutOfRangeException_GivenEndIndexGreaterThanOrEqualToCount() { Assert.Throws(() => new List().RemoveRange(..0)); - Assert.Throws(() => new List {1}.RemoveRange(..2)); + Assert.Throws(() => new List { 1 }.RemoveRange(..2)); } [Test] @@ -208,7 +208,7 @@ public void RemoveRange_ShouldRemoveElements_GivenList() list.RemoveRange(2..5); Assert.That(list, Has.Count.EqualTo(6)); - CollectionAssert.AreEqual(new[] {1, 2, 7, 8, 9, 10}, list); + Assert.That(list, Is.EqualTo(new[] { 1, 2, 7, 8, 9, 10 }).AsCollection); } [Test] @@ -217,11 +217,11 @@ public void Shuffle_ShouldReorder_GivenNotNull() var list = new List(Enumerable.Range(1, 52)); // 52! chance of being shuffled to the same order var shuffled = new List(list); - CollectionAssert.AreEqual(list, shuffled); + Assert.That(shuffled, Is.EqualTo(list).AsCollection); shuffled.Shuffle(); - CollectionAssert.AreNotEqual(list, shuffled); + Assert.That(shuffled, Is.Not.EqualTo(list).AsCollection); } [Test] @@ -233,23 +233,23 @@ public void Shuffle_ShouldThrow_GivenNull() [Test] public void Slice_ShouldReturnCorrectValue_GivenStartIndex() { - int[] array = {0, 1, 2, 3, 4, 5}; - CollectionAssert.AreEqual(new[] {2, 3, 4, 5}, array.Slice(2).ToArray()); + int[] array = { 0, 1, 2, 3, 4, 5 }; + Assert.That(array.Slice(2).ToArray(), Is.EqualTo(new[] { 2, 3, 4, 5 }).AsCollection); } [Test] public void Slice_ShouldReturnCorrectValue_GivenStartIndexAndLength() { - int[] array = {0, 1, 2, 3, 4, 5}; - CollectionAssert.AreEqual(new[] {2, 3, 4}, array.Slice(2, 3).ToArray()); + int[] array = { 0, 1, 2, 3, 4, 5 }; + Assert.That(array.Slice(2, 3).ToArray(), Is.EqualTo(new[] { 2, 3, 4 }).AsCollection); } [Test] public void Slice_ShouldReturnEmptyList_ForEmptyList() { int[] array = Array.Empty(); - CollectionAssert.AreEqual(Array.Empty(), array.Slice(0).ToArray()); - CollectionAssert.AreEqual(Array.Empty(), array.Slice(0, 0).ToArray()); + Assert.That(array.Slice(0).ToArray(), Is.EqualTo(Array.Empty()).AsCollection); + Assert.That(array.Slice(0, 0).ToArray(), Is.EqualTo(Array.Empty()).AsCollection); } [Test] @@ -278,7 +278,7 @@ public void Slice_ShouldThrowArgumentOutOfRangeException_GivenNegativeStartIndex [Test] public void Slice_ShouldThrowArgumentOutOfRangeException_GivenInvalidStartIndexCountPair() { - int[] array = {0, 1, 2}; + int[] array = { 0, 1, 2 }; Assert.Throws(() => array.Slice(2, 4)); } @@ -297,18 +297,18 @@ public void Swap_ShouldThrowArgumentNullException_GivenNullTarget() [Test] public void Swap_ShouldSwapElements_GivenMatchingElementCount() { - var first = new List {1, 2, 3}; - var second = new List {4, 5, 6}; + var first = new List { 1, 2, 3 }; + var second = new List { 4, 5, 6 }; first.Swap(second); - CollectionAssert.AreEqual(new[] {4, 5, 6}, first, string.Join(' ', first)); - CollectionAssert.AreEqual(new[] {1, 2, 3}, second, string.Join(' ', second)); + Assert.That(first, Is.EqualTo(new[] { 4, 5, 6 }).AsCollection, string.Join(' ', first)); + Assert.That(second, Is.EqualTo(new[] { 1, 2, 3 }).AsCollection, string.Join(' ', second)); first.Swap(second); - CollectionAssert.AreEqual(new[] {1, 2, 3}, first, string.Join(' ', first)); - CollectionAssert.AreEqual(new[] {4, 5, 6}, second, string.Join(' ', second)); + Assert.That(first, Is.EqualTo(new[] { 1, 2, 3 }).AsCollection, string.Join(' ', first)); + Assert.That(second, Is.EqualTo(new[] { 4, 5, 6 }).AsCollection, string.Join(' ', second)); } [Test] @@ -322,16 +322,16 @@ public void Swap_ShouldSwapElements_GivenDifferentElementCount() 4, 5 }; - var second = new List {6, 7}; + var second = new List { 6, 7 }; first.Swap(second); - CollectionAssert.AreEqual(new[] {6, 7}, first, string.Join(' ', first)); - CollectionAssert.AreEqual(new[] {1, 2, 3, 4, 5}, second, string.Join(' ', second)); + Assert.That(first, Is.EqualTo(new[] { 6, 7 }).AsCollection, string.Join(' ', first)); + Assert.That(second, Is.EqualTo(new[] { 1, 2, 3, 4, 5 }).AsCollection, string.Join(' ', second)); first.Swap(second); - CollectionAssert.AreEqual(new[] {1, 2, 3, 4, 5}, first, string.Join(' ', first)); - CollectionAssert.AreEqual(new[] {6, 7}, second, string.Join(' ', second)); + Assert.That(first, Is.EqualTo(new[] { 1, 2, 3, 4, 5 }).AsCollection, string.Join(' ', first)); + Assert.That(second, Is.EqualTo(new[] { 6, 7 }).AsCollection, string.Join(' ', second)); } } diff --git a/X10D.Tests/src/Collections/SpanTest.cs b/X10D.Tests/src/Collections/SpanTest.cs index 114336e97..47175f08b 100644 --- a/X10D.Tests/src/Collections/SpanTest.cs +++ b/X10D.Tests/src/Collections/SpanTest.cs @@ -31,7 +31,7 @@ public void Count_ShouldReturn0_GivenEmptyReadOnlySpan() [Test] public void Count_ShouldReturn8_GivenSpanWith8MatchingElements() { - Span span = stackalloc int[16] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2}; + Span span = stackalloc int[16] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 }; int count = span.Count(2); @@ -41,7 +41,7 @@ public void Count_ShouldReturn8_GivenSpanWith8MatchingElements() [Test] public void Count_ShouldReturn8_GivenReadOnlySpanWith8MatchingElements() { - ReadOnlySpan span = stackalloc int[16] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2}; + ReadOnlySpan span = stackalloc int[16] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 }; int count = span.Count(2); @@ -51,25 +51,25 @@ public void Count_ShouldReturn8_GivenReadOnlySpanWith8MatchingElements() [Test] public void Replace_ShouldReplaceAllElements_GivenSpanOfInt32() { - Span span = stackalloc int[16] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2}; + Span span = stackalloc int[16] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 }; span.Replace(2, 4); - Assert.That(span.ToArray(), Is.EqualTo(new[] {1, 4, 3, 4, 5, 4, 7, 4, 9, 4, 11, 4, 13, 4, 15, 4})); + Assert.That(span.ToArray(), Is.EqualTo(new[] { 1, 4, 3, 4, 5, 4, 7, 4, 9, 4, 11, 4, 13, 4, 15, 4 })); } [Test] public void Replace_ShouldReplaceAllElements_GivenSpanOfChar() { - Span chars = stackalloc char[12] {'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!'}; + Span chars = stackalloc char[12] { 'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!' }; chars.Replace('l', 'w'); - CollectionAssert.AreEqual(chars.ToArray(), "Hewwo worwd!".ToCharArray()); + Assert.That("Hewwo worwd!".ToCharArray(), Is.EqualTo(chars.ToArray()).AsCollection); } [Test] public void Replace_ShouldDoNothing_GivenSpanWithNoMatchingElements() { - Span span = stackalloc int[16] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2}; + Span span = stackalloc int[16] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 }; span.Replace(4, 8); - Assert.That(span.ToArray(), Is.EqualTo(new[] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2})); + Assert.That(span.ToArray(), Is.EqualTo(new[] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 })); } #if !NET9_0_OR_GREATER diff --git a/X10D.Tests/src/Core/CoreTests.cs b/X10D.Tests/src/Core/CoreTests.cs index a5df6ac43..6e46d935a 100644 --- a/X10D.Tests/src/Core/CoreTests.cs +++ b/X10D.Tests/src/Core/CoreTests.cs @@ -63,7 +63,7 @@ public void RepeatValue_ShouldContainRepeatedValue_GivenValue(object o) // ReSharper disable once PossibleMultipleEnumeration object[] array = enumerable.ToArray(); Assert.That(array, Has.Length.EqualTo(10)); - CollectionAssert.AreEqual(new[] {o, o, o, o, o, o, o, o, o, o}, array); + Assert.That(array, Is.EqualTo(new[] { o, o, o, o, o, o, o, o, o, o }).AsCollection); } [Test] diff --git a/X10D.Tests/src/Core/SpanTest.cs b/X10D.Tests/src/Core/SpanTest.cs index 743a55ef3..9b3673b93 100644 --- a/X10D.Tests/src/Core/SpanTest.cs +++ b/X10D.Tests/src/Core/SpanTest.cs @@ -1,4 +1,3 @@ -using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.X86; using NUnit.Framework; using X10D.Core; diff --git a/X10D.Tests/src/Drawing/PolygonFTests.cs b/X10D.Tests/src/Drawing/PolygonFTests.cs index 9052c9867..a5c54feb6 100644 --- a/X10D.Tests/src/Drawing/PolygonFTests.cs +++ b/X10D.Tests/src/Drawing/PolygonFTests.cs @@ -85,7 +85,7 @@ public void CopyConstructor_ShouldCopyVertices_GivenPolygon() // we cannot use CollectionAssert here for reasons I am not entirely sure of. // it seems to dislike casting from IReadOnlyList to ICollection. but okay. - CollectionAssert.AreEqual(first.Vertices, second.Vertices); + Assert.That(second.Vertices, Is.EqualTo(first.Vertices).AsCollection); // assert that the empty polygon was not modified Assert.That(PolygonF.Empty.VertexCount, Is.Zero); @@ -178,7 +178,7 @@ public void op_Explicit_ShouldReturnEquivalentCircle_GivenCircle() Assert.That(converted, Is.EqualTo((Polygon)polygon)); Assert.That(converted.IsConvex, Is.EqualTo(polygon.IsConvex)); Assert.That(converted.VertexCount, Is.EqualTo(polygon.VertexCount)); - CollectionAssert.AreEqual(polygon.Vertices, converted.Vertices.Select(p => (PointF)p)); + Assert.That(converted.Vertices.Select(p => (PointF)p), Is.EqualTo(polygon.Vertices).AsCollection); }); } @@ -194,7 +194,7 @@ public void op_Implicit_ShouldReturnEquivalentCircle_GivenCircle() Assert.That(converted == polygon); Assert.That(converted.IsConvex, Is.EqualTo(polygon.IsConvex)); Assert.That(converted.VertexCount, Is.EqualTo(polygon.VertexCount)); - CollectionAssert.AreEqual(converted.Vertices, polygon.Vertices.Select(p => (PointF)p)); + Assert.That(polygon.Vertices.Select(p => (PointF)p), Is.EqualTo(converted.Vertices).AsCollection); }); } diff --git a/X10D.Tests/src/Drawing/PolyhedronTests.cs b/X10D.Tests/src/Drawing/PolyhedronTests.cs index 30545e7c5..4a81ec78e 100644 --- a/X10D.Tests/src/Drawing/PolyhedronTests.cs +++ b/X10D.Tests/src/Drawing/PolyhedronTests.cs @@ -75,7 +75,7 @@ public void CopyConstructor_ShouldCopyVertices_GivenPolyhedron() // we cannot use CollectionAssert here for reasons I am not entirely sure of. // it seems to dislike casting from IReadOnlyList to ICollection. but okay. - CollectionAssert.AreEqual(first.Vertices, second.Vertices); + Assert.That(second.Vertices, Is.EqualTo(first.Vertices).AsCollection); // assert that the empty polyhedron was not modified Assert.That(Polyhedron.Empty.VertexCount, Is.Zero); @@ -148,11 +148,11 @@ public void op_Implicit_ShouldReturnEquivalentPolyhedron_GivenPolyhedron() Assert.That(converted, Is.EqualTo((Polyhedron)polygon)); Assert.That(converted.VertexCount, Is.EqualTo(polygon.VertexCount)); - CollectionAssert.AreEqual(converted.Vertices, polygon.Vertices.Select(p => + Assert.That(polygon.Vertices.Select(p => { var point = p.ToVector2(); return new Vector3(point.X, point.Y, 0); - })); + }), Is.EqualTo(converted.Vertices).AsCollection); }); } @@ -166,11 +166,11 @@ public void op_Implicit_ShouldReturnEquivalentPolyhedron_GivenPolyhedronF() { Assert.That(converted, Is.EqualTo((Polyhedron)polygon)); Assert.That(converted.VertexCount, Is.EqualTo(polygon.VertexCount)); - CollectionAssert.AreEqual(converted.Vertices, polygon.Vertices.Select(p => + Assert.That(converted.Vertices, Is.EqualTo(polygon.Vertices.Select(p => { var point = p.ToVector2(); return new Vector3(point.X, point.Y, 0); - })); + })).AsCollection); }); } diff --git a/X10D.Tests/src/Hosting/ServiceCollectionTests.cs b/X10D.Tests/src/Hosting/ServiceCollectionTests.cs index d9a8351c9..7bc78d160 100644 --- a/X10D.Tests/src/Hosting/ServiceCollectionTests.cs +++ b/X10D.Tests/src/Hosting/ServiceCollectionTests.cs @@ -23,8 +23,8 @@ public void AddHostedSingleton_ShouldRegisterServiceAsSingletonAndAsHostedServic { Assert.That(service, Is.Not.Null); Assert.That(hostedService, Is.Not.Null); - Assert.IsAssignableFrom(service); - Assert.IsAssignableFrom(hostedService); + Assert.That(service, Is.AssignableFrom()); + Assert.That(hostedService, Is.AssignableFrom()); Assert.That(hostedService, Is.SameAs(service)); }); } @@ -44,8 +44,8 @@ public void AddHostedSingleton_ShouldRegisterServiceAsSingletonAndAsHostedServic { Assert.That(service, Is.Not.Null); Assert.That(hostedService, Is.Not.Null); - Assert.IsAssignableFrom(service); - Assert.IsAssignableFrom(hostedService); + Assert.That(service, Is.AssignableFrom()); + Assert.That(hostedService, Is.AssignableFrom()); Assert.That(hostedService, Is.SameAs(service)); }); } @@ -65,8 +65,8 @@ public void AddHostedSingleton_ShouldRegisterServiceTypeAsSingletonAndAsHostedSe { Assert.That(service, Is.Not.Null); Assert.That(hostedService, Is.Not.Null); - Assert.IsAssignableFrom(service); - Assert.IsAssignableFrom(hostedService); + Assert.That(service, Is.AssignableFrom()); + Assert.That(hostedService, Is.AssignableFrom()); Assert.That(hostedService, Is.SameAs(service)); }); } @@ -86,8 +86,8 @@ public void AddHostedSingleton_ShouldRegisterServiceTypeAsSingletonAndAsHostedSe { Assert.That(service, Is.Not.Null); Assert.That(hostedService, Is.Not.Null); - Assert.IsAssignableFrom(service); - Assert.IsAssignableFrom(hostedService); + Assert.That(service, Is.AssignableFrom()); + Assert.That(hostedService, Is.AssignableFrom()); Assert.That(hostedService, Is.SameAs(service)); }); } diff --git a/X10D.Tests/src/IO/BooleanTests.cs b/X10D.Tests/src/IO/BooleanTests.cs index 87e2075fd..99bd6067a 100644 --- a/X10D.Tests/src/IO/BooleanTests.cs +++ b/X10D.Tests/src/IO/BooleanTests.cs @@ -10,7 +10,7 @@ internal class BooleanTests public void GetBytes_ReturnsArrayContaining1() { const bool value = true; - CollectionAssert.AreEqual(new byte[] {1}, value.GetBytes()); + Assert.That(value.GetBytes(), Is.EqualTo(new byte[] { 1 }).AsCollection); } [Test] @@ -19,7 +19,7 @@ public void TryWriteBytes_ReturnsTrue_FillsSpanContaining1_GivenLargeEnoughSpan( const bool value = true; Span buffer = stackalloc byte[1]; Assert.That(value.TryWriteBytes(buffer)); - CollectionAssert.AreEqual(new byte[] {1}, buffer.ToArray()); + Assert.That(buffer.ToArray(), Is.EqualTo(new byte[] { 1 }).AsCollection); } [Test] diff --git a/X10D.Tests/src/IO/ByteTests.cs b/X10D.Tests/src/IO/ByteTests.cs index 433cc09b3..1c9d1c933 100644 --- a/X10D.Tests/src/IO/ByteTests.cs +++ b/X10D.Tests/src/IO/ByteTests.cs @@ -10,16 +10,19 @@ internal class ByteTests public void GetBytes_ReturnsArrayContainingItself() { const byte value = 0xFF; - CollectionAssert.AreEqual(new[] {value}, value.GetBytes()); + Assert.That(value.GetBytes(), Is.EqualTo(new[] { value }).AsCollection); } [Test] public void TryWriteBytes_ReturnsTrue_FillsSpanContainingItself_GivenLargeEnoughSpan() { const byte value = 0xFF; - Span buffer = stackalloc byte[1]; - Assert.That(value.TryWriteBytes(buffer)); - CollectionAssert.AreEqual(new[] {value}, buffer.ToArray()); + Assert.Multiple(() => + { + Span buffer = stackalloc byte[1]; + Assert.That(value.TryWriteBytes(buffer)); + Assert.That(buffer.ToArray(), Is.EqualTo(new[] { value }).AsCollection); + }); } [Test] diff --git a/X10D.Tests/src/IO/DecimalTests.cs b/X10D.Tests/src/IO/DecimalTests.cs index 46e70776c..8a64198cc 100644 --- a/X10D.Tests/src/IO/DecimalTests.cs +++ b/X10D.Tests/src/IO/DecimalTests.cs @@ -14,7 +14,7 @@ public void GetBigEndianBytes_ShouldReturnBytes_InBigEndian() byte[] bytes = value.GetBigEndianBytes(); - CollectionAssert.AreEqual(expected, bytes); + Assert.That(bytes, Is.EqualTo(expected).AsCollection); } [Test] @@ -25,7 +25,7 @@ public void GetLittleEndianBytes_ShouldReturnBytes_InLittleEndian() byte[] bytes = value.GetLittleEndianBytes(); - CollectionAssert.AreEqual(expected, bytes); + Assert.That(bytes, Is.EqualTo(expected).AsCollection); } [Test] @@ -34,10 +34,12 @@ public void TryWriteBigEndianBytes_ShouldWriteBytes_InBigEndian() const decimal value = 1234m; byte[] expected = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 210]; - Span bytes = stackalloc byte[16]; - Assert.That(value.TryWriteBigEndianBytes(bytes)); - - CollectionAssert.AreEqual(expected, bytes.ToArray()); + Assert.Multiple(() => + { + Span bytes = stackalloc byte[16]; + Assert.That(value.TryWriteBigEndianBytes(bytes)); + Assert.That(bytes.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] @@ -46,10 +48,12 @@ public void TryWriteLittleEndianBytes_ShouldWriteBytes_InLittleEndian() const decimal value = 1234m; byte[] expected = [210, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - Span bytes = stackalloc byte[16]; - Assert.That(value.TryWriteLittleEndianBytes(bytes)); - - CollectionAssert.AreEqual(expected, bytes.ToArray()); + Assert.Multiple(() => + { + Span bytes = stackalloc byte[16]; + Assert.That(value.TryWriteLittleEndianBytes(bytes)); + Assert.That(bytes.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] diff --git a/X10D.Tests/src/IO/DoubleTests.cs b/X10D.Tests/src/IO/DoubleTests.cs index 66f15fee5..99ae227a5 100644 --- a/X10D.Tests/src/IO/DoubleTests.cs +++ b/X10D.Tests/src/IO/DoubleTests.cs @@ -13,7 +13,7 @@ public void GetBigEndianBytes_ReturnsCorrectValue() var expected = new byte[] { 0x40, 0x45, 0x40, 0, 0, 0, 0, 0 }; byte[] actual = value.GetBigEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -23,7 +23,7 @@ public void GetLittleEndianBytes_ReturnsCorrectValue() var expected = new byte[] { 0, 0, 0, 0, 0, 0x40, 0x45, 0x40 }; byte[] actual = value.GetLittleEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -32,9 +32,12 @@ public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly() const double value = 42.5; var expected = new byte[] { 0x40, 0x45, 0x40, 0, 0, 0, 0, 0 }; - Span actual = stackalloc byte[8]; - Assert.That(value.TryWriteBigEndianBytes(actual)); - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[8]; + Assert.That(value.TryWriteBigEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] @@ -43,9 +46,12 @@ public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly() const double value = 42.5; var expected = new byte[] { 0, 0, 0, 0, 0, 0x40, 0x45, 0x40 }; - Span actual = stackalloc byte[8]; - Assert.That(value.TryWriteLittleEndianBytes(actual)); - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[8]; + Assert.That(value.TryWriteLittleEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] diff --git a/X10D.Tests/src/IO/FileInfoTests.cs b/X10D.Tests/src/IO/FileInfoTests.cs index 319e864ac..aff685e3a 100644 --- a/X10D.Tests/src/IO/FileInfoTests.cs +++ b/X10D.Tests/src/IO/FileInfoTests.cs @@ -29,7 +29,7 @@ public void GetHashSha1ShouldBeCorrect() try { byte[] hash = new FileInfo(fileName).GetHash(); - CollectionAssert.AreEqual(expectedHash, hash); + Assert.That(hash, Is.EqualTo(expectedHash).AsCollection); } finally { @@ -58,10 +58,14 @@ public void TryWriteHashSha1ShouldBeCorrect() try { - Span hash = stackalloc byte[20]; - new FileInfo(fileName).TryWriteHash(hash, out int bytesWritten); - Assert.That(bytesWritten, Is.EqualTo(expectedHash.Length)); - CollectionAssert.AreEqual(expectedHash, hash.ToArray()); + Assert.Multiple(() => + { + Span hash = stackalloc byte[20]; + new FileInfo(fileName).TryWriteHash(hash, out int bytesWritten); + + Assert.That(bytesWritten, Is.EqualTo(expectedHash.Length)); + Assert.That(hash.ToArray(), Is.EqualTo(expectedHash).AsCollection); + }); } finally { diff --git a/X10D.Tests/src/IO/Int16Tests.cs b/X10D.Tests/src/IO/Int16Tests.cs index 6b03d4a83..ad6a1469e 100644 --- a/X10D.Tests/src/IO/Int16Tests.cs +++ b/X10D.Tests/src/IO/Int16Tests.cs @@ -13,7 +13,7 @@ public void GetLittleEndianBytes_ReturnsCorrectValue() byte[] expected = { 0x0F, 0 }; byte[] actual = value.GetLittleEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -23,7 +23,7 @@ public void GetBigEndianBytes_ReturnsCorrectValue() byte[] expected = { 0, 0x0F }; byte[] actual = value.GetBigEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -32,9 +32,12 @@ public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly() const short value = 0x0F; byte[] expected = { 0x0F, 0 }; - Span actual = stackalloc byte[2]; - Assert.That(value.TryWriteLittleEndianBytes(actual)); - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[2]; + Assert.That(value.TryWriteLittleEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] @@ -43,9 +46,12 @@ public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly() const short value = 0x0F; byte[] expected = { 0, 0x0F }; - Span actual = stackalloc byte[2]; - Assert.That(value.TryWriteBigEndianBytes(actual)); - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[2]; + Assert.That(value.TryWriteBigEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] diff --git a/X10D.Tests/src/IO/Int32Tests.cs b/X10D.Tests/src/IO/Int32Tests.cs index 01c7990ca..634426fdf 100644 --- a/X10D.Tests/src/IO/Int32Tests.cs +++ b/X10D.Tests/src/IO/Int32Tests.cs @@ -13,7 +13,7 @@ public void GetBigEndianBytes_ReturnsCorrectValue() var expected = new byte[] { 0, 0, 0, 0x0F }; byte[] actual = value.GetBigEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -23,7 +23,7 @@ public void GetLittleEndianBytes_ReturnsCorrectValue() var expected = new byte[] { 0x0F, 0, 0, 0 }; byte[] actual = value.GetLittleEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -32,9 +32,12 @@ public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly() const int value = 0x0F; var expected = new byte[] { 0, 0, 0, 0x0F }; - Span actual = stackalloc byte[4]; - Assert.That(value.TryWriteBigEndianBytes(actual)); - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[4]; + Assert.That(value.TryWriteBigEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] @@ -43,9 +46,12 @@ public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly() const int value = 0x0F; var expected = new byte[] { 0x0F, 0, 0, 0 }; - Span actual = stackalloc byte[4]; - Assert.That(value.TryWriteLittleEndianBytes(actual)); - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[4]; + Assert.That(value.TryWriteLittleEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] diff --git a/X10D.Tests/src/IO/Int64Tests.cs b/X10D.Tests/src/IO/Int64Tests.cs index c331369af..d4751be93 100644 --- a/X10D.Tests/src/IO/Int64Tests.cs +++ b/X10D.Tests/src/IO/Int64Tests.cs @@ -13,7 +13,7 @@ public void GetLittleEndianBytes_ReturnsCorrectValue() byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 }; byte[] actual = value.GetLittleEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -23,7 +23,7 @@ public void GetBigEndianBytes_ReturnsCorrectValue() byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F }; byte[] actual = value.GetBigEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -32,9 +32,12 @@ public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly() const long value = 0x0F; byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 }; - Span actual = stackalloc byte[8]; - Assert.That(value.TryWriteLittleEndianBytes(actual)); - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[8]; + Assert.That(value.TryWriteLittleEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] @@ -43,9 +46,12 @@ public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly() const long value = 0x0F; byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F }; - Span actual = stackalloc byte[8]; - Assert.That(value.TryWriteBigEndianBytes(actual)); - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[8]; + Assert.That(value.TryWriteBigEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] diff --git a/X10D.Tests/src/IO/SByteTests.cs b/X10D.Tests/src/IO/SByteTests.cs index c9486e2eb..e7d3d6ec7 100644 --- a/X10D.Tests/src/IO/SByteTests.cs +++ b/X10D.Tests/src/IO/SByteTests.cs @@ -10,16 +10,19 @@ internal class SByteTests public void GetBytes_ReturnsArrayContainingItself() { const sbyte value = 0x0F; - CollectionAssert.AreEqual(new[] {(byte)value}, value.GetBytes()); + Assert.That(value.GetBytes(), Is.EqualTo(new[] { (byte)value }).AsCollection); } [Test] public void TryWriteBytes_ReturnsTrue_FillsSpanContainingItself_GivenLargeEnoughSpan() { const sbyte value = 0x0F; - Span buffer = stackalloc byte[1]; - Assert.That(value.TryWriteBytes(buffer)); - CollectionAssert.AreEqual(new[] {(byte)value}, buffer.ToArray()); + Assert.Multiple(() => + { + Span buffer = stackalloc byte[1]; + Assert.That(value.TryWriteBytes(buffer)); + Assert.That(buffer.ToArray(), Is.EqualTo(new[] { (byte)value }).AsCollection); + }); } [Test] diff --git a/X10D.Tests/src/IO/SingleTests.cs b/X10D.Tests/src/IO/SingleTests.cs index 984f8a417..1dd325a9f 100644 --- a/X10D.Tests/src/IO/SingleTests.cs +++ b/X10D.Tests/src/IO/SingleTests.cs @@ -13,7 +13,7 @@ public void GetBigEndianBytes_ReturnsCorrectValue() var expected = new byte[] { 0x42, 0x2A, 0, 0 }; byte[] actual = value.GetBigEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -23,7 +23,7 @@ public void GetLittleEndianBytes_ReturnsCorrectValue() var expected = new byte[] { 0, 0, 0x2A, 0x42 }; byte[] actual = value.GetLittleEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -32,9 +32,12 @@ public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly() const float value = 42.5f; var expected = new byte[] { 0x42, 0x2A, 0, 0 }; - Span actual = stackalloc byte[4]; - Assert.That(value.TryWriteBigEndianBytes(actual)); - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[4]; + Assert.That(value.TryWriteBigEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] @@ -43,9 +46,12 @@ public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly() const float value = 42.5f; var expected = new byte[] { 0, 0, 0x2A, 0x42 }; - Span actual = stackalloc byte[4]; - Assert.That(value.TryWriteLittleEndianBytes(actual)); - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[4]; + Assert.That(value.TryWriteLittleEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] diff --git a/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs b/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs index 15e753847..91aed0d30 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs @@ -45,16 +45,19 @@ public void WriteBigEndian_ShouldWriteBigEndian_GivenDecimalArgument() Assert.That(stream.Position, Is.EqualTo(16)); stream.Position = 0; - Span actual = stackalloc byte[16]; - ReadOnlySpan expected = stackalloc byte[] + Assert.Multiple(() => { - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x68 - }; - int read = stream.Read(actual); - Trace.WriteLine(string.Join(' ', actual.ToArray())); + Span actual = stackalloc byte[16]; + ReadOnlySpan expected = stackalloc byte[] + { + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x68 + }; + int read = stream.Read(actual); + Trace.WriteLine(string.Join(' ', actual.ToArray())); - Assert.That(read, Is.EqualTo(16)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(16)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } [Test] @@ -65,16 +68,19 @@ public void WriteLittleEndian_ShouldWriteLittleEndian_GivenDecimalArgument() Assert.That(stream.Position, Is.EqualTo(16)); stream.Position = 0; - Span actual = stackalloc byte[16]; - ReadOnlySpan expected = stackalloc byte[] + Assert.Multiple(() => { - 0x68, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 - }; - int read = stream.Read(actual); + Span actual = stackalloc byte[16]; + ReadOnlySpan expected = stackalloc byte[] + { + 0x68, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 + }; + int read = stream.Read(actual); - Trace.WriteLine(string.Join(", ", actual.ToArray().Select(b => $"0x{b:X2}"))); + Trace.WriteLine(string.Join(", ", actual.ToArray().Select(b => $"0x{b:X2}"))); - Assert.That(read, Is.EqualTo(16)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(16)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } } diff --git a/X10D.Tests/src/IO/StreamTests.WriteDouble.cs b/X10D.Tests/src/IO/StreamTests.WriteDouble.cs index 8828325af..ba8201147 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteDouble.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteDouble.cs @@ -44,12 +44,15 @@ public void WriteBigEndian_ShouldWriteBigEndian_GivenDoubleArgument() Assert.That(stream.Position, Is.EqualTo(8)); stream.Position = 0; - Span actual = stackalloc byte[8]; - ReadOnlySpan expected = stackalloc byte[] { 0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[8]; + ReadOnlySpan expected = stackalloc byte[] { 0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(8)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(8)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } [Test] @@ -60,11 +63,14 @@ public void WriteLittleEndian_ShouldWriteLittleEndian_GivenDoubleArgument() Assert.That(stream.Position, Is.EqualTo(8)); stream.Position = 0; - Span actual = stackalloc byte[8]; - ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7A, 0x40 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[8]; + ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7A, 0x40 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(8)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(8)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } } diff --git a/X10D.Tests/src/IO/StreamTests.WriteInt16.cs b/X10D.Tests/src/IO/StreamTests.WriteInt16.cs index bc38dd8c8..a49513bd0 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteInt16.cs @@ -44,12 +44,15 @@ public void WriteBigEndian_ShouldWriteBigEndian_GivenInt16Argument() Assert.That(stream.Position, Is.EqualTo(2)); stream.Position = 0; - Span actual = stackalloc byte[2]; - ReadOnlySpan expected = stackalloc byte[] { 0x01, 0xA4 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[2]; + ReadOnlySpan expected = stackalloc byte[] { 0x01, 0xA4 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(2)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(2)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } [Test] @@ -60,11 +63,14 @@ public void WriteLittleEndian_ShouldWriteLittleEndian_GivenInt16Argument() Assert.That(stream.Position, Is.EqualTo(2)); stream.Position = 0; - Span actual = stackalloc byte[2]; - ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[2]; + ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(2)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(2)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } } diff --git a/X10D.Tests/src/IO/StreamTests.WriteInt32.cs b/X10D.Tests/src/IO/StreamTests.WriteInt32.cs index 75688f984..7534e2e2c 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteInt32.cs @@ -44,12 +44,15 @@ public void WriteBigEndian_ShouldWriteBigEndian_GivenInt32Argument() Assert.That(stream.Position, Is.EqualTo(4)); stream.Position = 0; - Span actual = stackalloc byte[4]; - ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[4]; + ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(4)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(4)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } [Test] @@ -60,11 +63,14 @@ public void WriteLittleEndian_ShouldWriteLittleEndian_GivenInt32Argument() Assert.That(stream.Position, Is.EqualTo(4)); stream.Position = 0; - Span actual = stackalloc byte[4]; - ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[4]; + ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(4)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(4)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } } diff --git a/X10D.Tests/src/IO/StreamTests.WriteInt64.cs b/X10D.Tests/src/IO/StreamTests.WriteInt64.cs index feeb67789..3a3fea553 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteInt64.cs @@ -44,12 +44,15 @@ public void WriteBigEndian_ShouldWriteBigEndian_GivenInt64Argument() Assert.That(stream.Position, Is.EqualTo(8)); stream.Position = 0; - Span actual = stackalloc byte[8]; - ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[8]; + ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(8)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(8)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } [Test] @@ -60,11 +63,14 @@ public void WriteLittleEndian_ShouldWriteLittleEndian_GivenLittleEndian() Assert.That(stream.Position, Is.EqualTo(8)); stream.Position = 0; - Span actual = stackalloc byte[8]; - ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[8]; + ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(8)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(8)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } } diff --git a/X10D.Tests/src/IO/StreamTests.WriteSingle.cs b/X10D.Tests/src/IO/StreamTests.WriteSingle.cs index 7df8eb8cc..b9a6db0b6 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteSingle.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteSingle.cs @@ -44,12 +44,15 @@ public void WriteBigEndian_ShouldWriteBigEndian_GivenSingleArgument() Assert.That(stream.Position, Is.EqualTo(4)); stream.Position = 0; - Span actual = stackalloc byte[4]; - ReadOnlySpan expected = stackalloc byte[] { 0x43, 0xD2, 0x00, 0x00 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[4]; + ReadOnlySpan expected = stackalloc byte[] { 0x43, 0xD2, 0x00, 0x00 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(4)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(4)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } [Test] @@ -60,11 +63,14 @@ public void WriteLittleEndian_ShouldWriteLittleEndian_GivenSingleArgument() Assert.That(stream.Position, Is.EqualTo(4)); stream.Position = 0; - Span actual = stackalloc byte[4]; - ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0xD2, 0x43 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[4]; + ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0xD2, 0x43 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(4)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(4)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } } diff --git a/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs b/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs index 7fde9f2bb..4f0be3dd3 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs @@ -44,12 +44,15 @@ public void WriteBigEndian_ShouldWriteBigEndian_GivenUInt16Endian() Assert.That(stream.Position, Is.EqualTo(2)); stream.Position = 0; - Span actual = stackalloc byte[2]; - ReadOnlySpan expected = stackalloc byte[] { 0x01, 0xA4 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[2]; + ReadOnlySpan expected = stackalloc byte[] { 0x01, 0xA4 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(2)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(2)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } [Test] @@ -60,11 +63,14 @@ public void WriteLittleEndian_ShouldWriteLittleEndian_GivenUInt16tleEndian() Assert.That(stream.Position, Is.EqualTo(2)); stream.Position = 0; - Span actual = stackalloc byte[2]; - ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[2]; + ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(2)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(2)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } } diff --git a/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs b/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs index e5eafb706..2c5815570 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs @@ -44,12 +44,15 @@ public void WriteBigEndian_ShouldWriteBigEndian_GivenUInt32Argument() Assert.That(stream.Position, Is.EqualTo(4)); stream.Position = 0; - Span actual = stackalloc byte[4]; - ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[4]; + ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(4)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(4)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } [Test] @@ -60,11 +63,14 @@ public void WriteLittleEndian_ShouldWriteLittleEndian_GivenUInt32Argument() Assert.That(stream.Position, Is.EqualTo(4)); stream.Position = 0; - Span actual = stackalloc byte[4]; - ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[4]; + ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(4)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(4)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } } diff --git a/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs b/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs index 5d8edcf6a..349f48907 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs @@ -44,12 +44,15 @@ public void WriteBigEndian_ShouldWriteBigEndian_GivenUInt64Argument() Assert.That(stream.Position, Is.EqualTo(8)); stream.Position = 0; - Span actual = stackalloc byte[8]; - ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[8]; + ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(8)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(8)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } [Test] @@ -60,11 +63,14 @@ public void WriteLittleEndian_ShouldWriteLittleEndian_GivenUInt64Argument() Assert.That(stream.Position, Is.EqualTo(8)); stream.Position = 0; - Span actual = stackalloc byte[8]; - ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - int read = stream.Read(actual); + Assert.Multiple(() => + { + Span actual = stackalloc byte[8]; + ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + int read = stream.Read(actual); - Assert.That(read, Is.EqualTo(8)); - CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray()); + Assert.That(read, Is.EqualTo(8)); + Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection); + }); } } diff --git a/X10D.Tests/src/IO/StreamTests.cs b/X10D.Tests/src/IO/StreamTests.cs index b522265c6..2857c16ae 100644 --- a/X10D.Tests/src/IO/StreamTests.cs +++ b/X10D.Tests/src/IO/StreamTests.cs @@ -26,7 +26,7 @@ public void GetHashSha1ShouldBeCorrect() byte[] hash = stream.GetHash(); Trace.WriteLine($"Hash: {BitConverter.ToString(hash)}"); Trace.WriteLine($"Expected: {BitConverter.ToString(expectedHash)}"); - CollectionAssert.AreEqual(expectedHash, hash); + Assert.That(hash, Is.EqualTo(expectedHash).AsCollection); } [Test] @@ -54,7 +54,7 @@ public void TryWriteHashSha1_ShouldBeCorrect() Span hash = stackalloc byte[20]; stream.TryWriteHash(hash, out int bytesWritten); Assert.That(bytesWritten, Is.EqualTo(expectedHash.Length)); - CollectionAssert.AreEqual(expectedHash, hash.ToArray()); + Assert.That(hash.ToArray(), Is.EqualTo(expectedHash).AsCollection); } [Test] diff --git a/X10D.Tests/src/IO/UInt16Tests.cs b/X10D.Tests/src/IO/UInt16Tests.cs index be9360ef7..e646553e6 100644 --- a/X10D.Tests/src/IO/UInt16Tests.cs +++ b/X10D.Tests/src/IO/UInt16Tests.cs @@ -13,7 +13,7 @@ public void GetLittleEndianBytes_ReturnsCorrectValue_WithEndianness() byte[] expected = { 0x0F, 0 }; byte[] actual = value.GetLittleEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -23,7 +23,7 @@ public void GetBigEndianBytes_ReturnsCorrectValue_WithEndianness() byte[] expected = { 0, 0x0F }; byte[] actual = value.GetBigEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -32,10 +32,12 @@ public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnough const ushort value = 0x0F; byte[] expected = { 0x0F, 0 }; - Span actual = stackalloc byte[2]; - Assert.That(value.TryWriteLittleEndianBytes(actual)); - - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[2]; + Assert.That(value.TryWriteLittleEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] @@ -44,10 +46,12 @@ public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpa const ushort value = 0x0F; byte[] expected = { 0, 0x0F }; - Span actual = stackalloc byte[2]; - Assert.That(value.TryWriteBigEndianBytes(actual)); - - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[2]; + Assert.That(value.TryWriteBigEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] diff --git a/X10D.Tests/src/IO/UInt32Tests.cs b/X10D.Tests/src/IO/UInt32Tests.cs index 784775918..588f2fb94 100644 --- a/X10D.Tests/src/IO/UInt32Tests.cs +++ b/X10D.Tests/src/IO/UInt32Tests.cs @@ -13,7 +13,7 @@ public void GetLittleEndianBytes_ReturnsCorrectValue_WithEndianness() byte[] expected = { 0x0F, 0, 0, 0 }; byte[] actual = value.GetLittleEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -23,7 +23,7 @@ public void GetBigEndianBytes_ReturnsCorrectValue_WithEndianness() byte[] expected = { 0, 0, 0, 0x0F }; byte[] actual = value.GetBigEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -32,10 +32,12 @@ public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnough const uint value = 0x0F; byte[] expected = { 0x0F, 0, 0, 0 }; - Span actual = stackalloc byte[4]; - Assert.That(value.TryWriteLittleEndianBytes(actual)); - - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[4]; + Assert.That(value.TryWriteLittleEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] @@ -44,10 +46,12 @@ public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpa const uint value = 0x0F; byte[] expected = { 0, 0, 0, 0x0F }; - Span actual = stackalloc byte[4]; - Assert.That(value.TryWriteBigEndianBytes(actual)); - - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[4]; + Assert.That(value.TryWriteBigEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] diff --git a/X10D.Tests/src/IO/UInt64Tests.cs b/X10D.Tests/src/IO/UInt64Tests.cs index e783e2a1c..07e38f4a4 100644 --- a/X10D.Tests/src/IO/UInt64Tests.cs +++ b/X10D.Tests/src/IO/UInt64Tests.cs @@ -13,7 +13,7 @@ public void GetLittleEndianBytes_ReturnsCorrectValue_WithEndianness() byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 }; byte[] actual = value.GetLittleEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -23,7 +23,7 @@ public void GetBigEndianBytes_ReturnsCorrectValue_WithEndianness() byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F }; byte[] actual = value.GetBigEndianBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -32,10 +32,12 @@ public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnough const ulong value = 0x0F; byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 }; - Span actual = stackalloc byte[8]; - Assert.That(value.TryWriteLittleEndianBytes(actual)); - - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[8]; + Assert.That(value.TryWriteLittleEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] @@ -44,10 +46,12 @@ public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpa const ulong value = 0x0F; byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F }; - Span actual = stackalloc byte[8]; - Assert.That(value.TryWriteBigEndianBytes(actual)); - - CollectionAssert.AreEqual(expected, actual.ToArray()); + Assert.Multiple(() => + { + Span actual = stackalloc byte[8]; + Assert.That(value.TryWriteBigEndianBytes(actual)); + Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection); + }); } [Test] diff --git a/X10D.Tests/src/Math/IsPrimeTests.cs b/X10D.Tests/src/Math/IsPrimeTests.cs index 452a28634..314bad0d7 100644 --- a/X10D.Tests/src/Math/IsPrimeTests.cs +++ b/X10D.Tests/src/Math/IsPrimeTests.cs @@ -142,7 +142,7 @@ public void ZeroToByteMaxValue() private static IReadOnlyList LoadPrimes() { using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("X10D.Tests.1000primes.txt"); - Assert.IsNotNull(stream); + Assert.That(stream, Is.Not.Null); using var reader = new StreamReader(stream, Encoding.UTF8); var primes = new List(); diff --git a/X10D.Tests/src/Text/CoreTests.cs b/X10D.Tests/src/Text/CoreTests.cs index 684fa266c..679164a9a 100644 --- a/X10D.Tests/src/Text/CoreTests.cs +++ b/X10D.Tests/src/Text/CoreTests.cs @@ -20,7 +20,11 @@ public void ToJsonShouldDeserializeEquivalent() int[] source = Enumerable.Range(1, 100).ToArray(); string json = source.ToJson(); int[]? target = json.FromJson(); - CollectionAssert.AreEqual(source, target); - CollectionAssert.AreEquivalent(source, target); + + Assert.Multiple(() => + { + Assert.That(target, Is.EqualTo(source).AsCollection); + Assert.That(target, Is.EquivalentTo(source)); + }); } } diff --git a/X10D.Tests/src/Text/EnumerableTests.cs b/X10D.Tests/src/Text/EnumerableTests.cs index ab6bfd057..8fbcec216 100644 --- a/X10D.Tests/src/Text/EnumerableTests.cs +++ b/X10D.Tests/src/Text/EnumerableTests.cs @@ -10,13 +10,13 @@ internal class EnumerableTests public void Grep_ShouldFilterCorrectly_GivenPattern() { int year = DateTime.Now.Year; - var source = new[] {"Hello", "World", "String 123", $"The year is {year}"}; - var expectedResult = new[] {"String 123", $"The year is {year}"}; + var source = new[] { "Hello", "World", "String 123", $"The year is {year}" }; + var expectedResult = new[] { "String 123", $"The year is {year}" }; const string pattern = /*lang=regex*/@"[0-9]+"; string[] actualResult = source.Grep(pattern).ToArray(); - CollectionAssert.AreEqual(expectedResult, actualResult); + Assert.That(actualResult, Is.EqualTo(expectedResult).AsCollection); } [Test] @@ -28,27 +28,27 @@ public void Grep_ShouldYieldNoResults_GivenEmptySource() const string pattern = /*lang=regex*/@"[0-9]+"; string[] actualResult = source.Grep(pattern).ToArray(); - CollectionAssert.AreEqual(expectedResult, actualResult); + Assert.That(actualResult, Is.EqualTo(expectedResult).AsCollection); } [Test] public void Grep_ShouldMatchUpperCase_GivenIgnoreCaseTrue() { int year = DateTime.Now.Year; - var source = new[] {"Hello", "WORLD", "String 123", $"The year is {year}"}; - var expectedResult = new[] {"WORLD"}; + var source = new[] { "Hello", "WORLD", "String 123", $"The year is {year}" }; + var expectedResult = new[] { "WORLD" }; const string pattern = /*lang=regex*/@"world"; string[] actualResult = source.Grep(pattern, true).ToArray(); - CollectionAssert.AreEqual(expectedResult, actualResult); + Assert.That(actualResult, Is.EqualTo(expectedResult).AsCollection); } [Test] public void Grep_ShouldNotMatchUpperCase_GivenIgnoreCaseFalse() { int year = DateTime.Now.Year; - var source = new[] {"Hello", "WORLD", "String 123", $"The year is {year}"}; + var source = new[] { "Hello", "WORLD", "String 123", $"The year is {year}" }; const string pattern = /*lang=regex*/@"world"; string[] actualResult = source.Grep(pattern, false).ToArray(); @@ -60,22 +60,28 @@ public void Grep_ShouldNotMatchUpperCase_GivenIgnoreCaseFalse() public void Grep_ShouldThrowArgumentNullException_GivenNullPattern() { IEnumerable source = Enumerable.Empty(); - Assert.Throws(() => source.Grep(null!).ToArray()); - Assert.Throws(() => source.Grep(null!, false).ToArray()); + Assert.Multiple(() => + { + Assert.Throws(() => source.Grep(null!).ToArray()); + Assert.Throws(() => source.Grep(null!, false).ToArray()); + }); } [Test] public void Grep_ShouldThrowArgumentNullException_GivenNullSource() { IEnumerable source = null!; - Assert.Throws(() => source.Grep("foo").ToArray()); - Assert.Throws(() => source.Grep("foo", false).ToArray()); + Assert.Multiple(() => + { + Assert.Throws(() => source.Grep("foo").ToArray()); + Assert.Throws(() => source.Grep("foo", false).ToArray()); + }); } [Test] public void Grep_ShouldYieldNoElements_GivenNoMatchingStrings() { - var source = new[] {"Hello", "World", "String"}; + var source = new[] { "Hello", "World", "String" }; const string pattern = /*lang=regex*/@"[0-9]+"; string[] actualResult = source.Grep(pattern).ToArray(); diff --git a/X10D.Tests/src/Text/StringBuilderReaderTests.cs b/X10D.Tests/src/Text/StringBuilderReaderTests.cs index 8575511b0..fc2f60f06 100644 --- a/X10D.Tests/src/Text/StringBuilderReaderTests.cs +++ b/X10D.Tests/src/Text/StringBuilderReaderTests.cs @@ -22,18 +22,21 @@ public void Read_ShouldReturnNextChar_GivenBuilder() { using var reader = new StringBuilderReader(new StringBuilder("Hello\nWorld")); - Assert.That(reader.Read(), Is.EqualTo('H')); - Assert.That(reader.Read(), Is.EqualTo('e')); - Assert.That(reader.Read(), Is.EqualTo('l')); - Assert.That(reader.Read(), Is.EqualTo('l')); - Assert.That(reader.Read(), Is.EqualTo('o')); - Assert.That(reader.Read(), Is.EqualTo('\n')); - Assert.That(reader.Read(), Is.EqualTo('W')); - Assert.That(reader.Read(), Is.EqualTo('o')); - Assert.That(reader.Read(), Is.EqualTo('r')); - Assert.That(reader.Read(), Is.EqualTo('l')); - Assert.That(reader.Read(), Is.EqualTo('d')); - Assert.That(reader.Read(), Is.EqualTo(-1)); + Assert.Multiple(() => + { + Assert.That(reader.Read(), Is.EqualTo('H')); + Assert.That(reader.Read(), Is.EqualTo('e')); + Assert.That(reader.Read(), Is.EqualTo('l')); + Assert.That(reader.Read(), Is.EqualTo('l')); + Assert.That(reader.Read(), Is.EqualTo('o')); + Assert.That(reader.Read(), Is.EqualTo('\n')); + Assert.That(reader.Read(), Is.EqualTo('W')); + Assert.That(reader.Read(), Is.EqualTo('o')); + Assert.That(reader.Read(), Is.EqualTo('r')); + Assert.That(reader.Read(), Is.EqualTo('l')); + Assert.That(reader.Read(), Is.EqualTo('d')); + Assert.That(reader.Read(), Is.EqualTo(-1)); + }); reader.Close(); } @@ -45,9 +48,12 @@ public void Read_ShouldPopulateArray_GivenBuilder() var array = new char[5]; int read = reader.Read(array, 0, 5); - Assert.That(read, Is.EqualTo(5)); - CollectionAssert.AreEqual("Hello".ToCharArray(), array); + Assert.Multiple(() => + { + Assert.That(read, Is.EqualTo(5)); + Assert.That(array, Is.EqualTo("Hello".ToCharArray()).AsCollection); + }); reader.Close(); } @@ -114,11 +120,14 @@ public void Read_ShouldPopulateSpan_GivenBuilder() { using var reader = new StringBuilderReader(new StringBuilder("Hello\nWorld")); - Span span = stackalloc char[5]; - int read = reader.Read(span); - Assert.That(read, Is.EqualTo(5)); + Assert.Multiple(() => + { + Span span = stackalloc char[5]; + int read = reader.Read(span); - CollectionAssert.AreEqual("Hello".ToCharArray(), span.ToArray()); + Assert.That(read, Is.EqualTo(5)); + Assert.That(span.ToArray(), Is.EqualTo("Hello".ToCharArray()).AsCollection); + }); reader.Close(); } @@ -130,9 +139,12 @@ public void ReadAsync_ShouldPopulateArray_GivenBuilder() var array = new char[5]; int read = reader.ReadAsync(array, 0, 5).GetAwaiter().GetResult(); - Assert.That(read, Is.EqualTo(5)); - CollectionAssert.AreEqual("Hello".ToCharArray(), array); + Assert.Multiple(() => + { + Assert.That(read, Is.EqualTo(5)); + Assert.That(array, Is.EqualTo("Hello".ToCharArray()).AsCollection); + }); reader.Close(); } @@ -144,9 +156,12 @@ public void ReadAsync_ShouldPopulateMemory_GivenBuilder() Memory memory = new char[5]; int read = reader.ReadAsync(memory).GetAwaiter().GetResult(); - Assert.That(read, Is.EqualTo(5)); - CollectionAssert.AreEqual("Hello".ToCharArray(), memory.ToArray()); + Assert.Multiple(() => + { + Assert.That(read, Is.EqualTo(5)); + Assert.That(memory.ToArray(), Is.EqualTo("Hello".ToCharArray()).AsCollection); + }); reader.Close(); } @@ -158,9 +173,12 @@ public void ReadBlock_ShouldPopulateArray_GivenBuilder() var array = new char[5]; int read = reader.ReadBlock(array, 0, 5); - Assert.That(read, Is.EqualTo(5)); - CollectionAssert.AreEqual("Hello".ToCharArray(), array); + Assert.Multiple(() => + { + Assert.That(read, Is.EqualTo(5)); + Assert.That(array, Is.EqualTo("Hello".ToCharArray()).AsCollection); + }); reader.Close(); } @@ -170,11 +188,14 @@ public void ReadBlock_ShouldPopulateSpan_GivenBuilder() { using var reader = new StringBuilderReader(new StringBuilder("Hello\nWorld")); - Span span = stackalloc char[5]; - int read = reader.ReadBlock(span); - Assert.That(read, Is.EqualTo(5)); + Assert.Multiple(() => + { + Span span = stackalloc char[5]; + int read = reader.ReadBlock(span); - CollectionAssert.AreEqual("Hello".ToCharArray(), span.ToArray()); + Assert.That(read, Is.EqualTo(5)); + Assert.That(span.ToArray(), Is.EqualTo("Hello".ToCharArray()).AsCollection); + }); reader.Close(); } @@ -200,9 +221,12 @@ public void ReadBlockAsync_ShouldPopulateArray_GivenBuilder() var array = new char[5]; int read = reader.ReadBlockAsync(array, 0, 5).GetAwaiter().GetResult(); - Assert.That(read, Is.EqualTo(5)); - CollectionAssert.AreEqual("Hello".ToCharArray(), array); + Assert.Multiple(() => + { + Assert.That(read, Is.EqualTo(5)); + Assert.That(array, Is.EqualTo("Hello".ToCharArray()).AsCollection); + }); reader.Close(); } @@ -214,9 +238,12 @@ public void ReadBlockAsync_ShouldPopulateMemory_GivenBuilder() Memory memory = new char[5]; int read = reader.ReadBlockAsync(memory).GetAwaiter().GetResult(); - Assert.That(read, Is.EqualTo(5)); - CollectionAssert.AreEqual("Hello".ToCharArray(), memory.ToArray()); + Assert.Multiple(() => + { + Assert.That(read, Is.EqualTo(5)); + Assert.That(memory.ToArray(), Is.EqualTo("Hello".ToCharArray()).AsCollection); + }); reader.Close(); } diff --git a/X10D.Tests/src/Text/StringTests.cs b/X10D.Tests/src/Text/StringTests.cs index d658b72af..5c0afe13d 100644 --- a/X10D.Tests/src/Text/StringTests.cs +++ b/X10D.Tests/src/Text/StringTests.cs @@ -423,7 +423,7 @@ public void FromJson_ShouldDeserializeCorrectly_GivenJsonString() var target = json.FromJson(); Assert.Multiple(() => { - Assert.IsInstanceOf(target); + Assert.That(target, Is.InstanceOf()); Assert.That(target.Values, Is.Not.Null); Assert.That(target.Values.Length, Is.EqualTo(3)); Assert.That(target.Values[0], Is.EqualTo(1)); @@ -438,7 +438,7 @@ public void GetBytes_ShouldReturnUtf8Bytes_GivenHelloWorld() var expected = new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 }; byte[] actual = "Hello World".GetBytes(); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -447,7 +447,7 @@ public void GetBytes_ShouldReturnAsciiBytes_GivenHelloWorld() var expected = new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 }; byte[] actual = "Hello World".GetBytes(Encoding.ASCII); - CollectionAssert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected).AsCollection); } [Test] @@ -1004,7 +1004,6 @@ public void WithWhiteSpaceAlternative_ShouldBeCorrect() private struct SampleStructure { - [JsonPropertyName("values")] - public int[] Values { get; set; } + [JsonPropertyName("values")] public int[] Values { get; set; } } } From 8e6e16700f557badc87f91e4d94b7db24bad0fda Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 13 Nov 2024 18:45:37 +0000 Subject: [PATCH 6/6] ci: add net9.0 test step --- .github/workflows/dotnet.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 1756f8cbe..ab038c6c2 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -38,6 +38,9 @@ jobs: - name: Test .NET 8 run: dotnet test --no-build --verbosity normal --configuration Release --framework net8.0 --collect:"XPlat Code Coverage" --results-directory test-results/net8.0 + - name: Test .NET 9 + run: dotnet test --no-build --verbosity normal --configuration Release --framework net9.0 --collect:"XPlat Code Coverage" --results-directory test-results/net9.0 + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4.0.0 with: