diff --git a/build/Community.Toolkit.Common.targets b/build/Community.Toolkit.Common.targets
index e04f18d08..f16aa5aca 100644
--- a/build/Community.Toolkit.Common.targets
+++ b/build/Community.Toolkit.Common.targets
@@ -16,4 +16,9 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj b/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj
index 3899341d0..5e782c0b3 100644
--- a/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj
+++ b/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/tests/CommunityToolkit.Common.UnitTests/Extensions/Test_TaskExtensions.cs b/tests/CommunityToolkit.Common.UnitTests/Extensions/Test_TaskExtensions.cs
index 86d6ec2aa..740a75a9c 100644
--- a/tests/CommunityToolkit.Common.UnitTests/Extensions/Test_TaskExtensions.cs
+++ b/tests/CommunityToolkit.Common.UnitTests/Extensions/Test_TaskExtensions.cs
@@ -34,7 +34,7 @@ public void Test_TaskExtensions_Generic_ReferenceType()
{
TaskCompletionSource tcs = new();
- Assert.AreEqual(null, tcs.Task.GetResultOrDefault());
+ Assert.IsNull(tcs.Task.GetResultOrDefault());
tcs.SetResult(nameof(Test_TaskExtensions_Generic_ReferenceType));
@@ -46,17 +46,17 @@ public void Test_TaskExtensions_ResultOrDefault()
{
TaskCompletionSource tcs = new();
- Assert.AreEqual(null, ((Task)tcs.Task).GetResultOrDefault());
+ Assert.IsNull(((Task)tcs.Task).GetResultOrDefault());
tcs.SetCanceled();
- Assert.AreEqual(null, ((Task)tcs.Task).GetResultOrDefault());
+ Assert.IsNull(((Task)tcs.Task).GetResultOrDefault());
tcs = new TaskCompletionSource();
tcs.SetException(new InvalidOperationException("Test"));
- Assert.AreEqual(null, ((Task)tcs.Task).GetResultOrDefault());
+ Assert.IsNull(((Task)tcs.Task).GetResultOrDefault());
tcs = new TaskCompletionSource();
@@ -68,7 +68,7 @@ public void Test_TaskExtensions_ResultOrDefault()
[TestMethod]
public void Test_TaskExtensions_ResultOrDefault_FromTaskCompleted()
{
- Assert.AreEqual(null, Task.CompletedTask.GetResultOrDefault());
+ Assert.IsNull(Task.CompletedTask.GetResultOrDefault());
}
[TestMethod]
@@ -85,8 +85,8 @@ public async Task Test_TaskExtensions_ResultOrDefault_FromAsyncTaskMethodBuilder
_ = await taskFromBuilder;
- Assert.AreEqual(((Task)taskFromBuilder).GetResultOrDefault(), "Test");
- Assert.AreEqual(taskFromBuilder.GetResultOrDefault(), "Test");
+ Assert.AreEqual("Test", ((Task)taskFromBuilder).GetResultOrDefault());
+ Assert.AreEqual("Test", taskFromBuilder.GetResultOrDefault());
}
[TestMethod]
@@ -118,17 +118,17 @@ public void Test_TaskExtensions_ResultOrDefault_OfT_String()
{
TaskCompletionSource tcs = new();
- Assert.AreEqual(null, tcs.Task.GetResultOrDefault());
+ Assert.IsNull(tcs.Task.GetResultOrDefault());
tcs.SetCanceled();
- Assert.AreEqual(null, tcs.Task.GetResultOrDefault());
+ Assert.IsNull(tcs.Task.GetResultOrDefault());
tcs = new TaskCompletionSource();
tcs.SetException(new InvalidOperationException("Test"));
- Assert.AreEqual(null, tcs.Task.GetResultOrDefault());
+ Assert.IsNull(tcs.Task.GetResultOrDefault());
tcs = new TaskCompletionSource();
diff --git a/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj b/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj
index 97eca8abe..9b9a7d83e 100644
--- a/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj
+++ b/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/tests/CommunityToolkit.Diagnostics.UnitTests/Extensions/Test_ValueTypeExtensions.cs b/tests/CommunityToolkit.Diagnostics.UnitTests/Extensions/Test_ValueTypeExtensions.cs
index 972dfff33..d9c6855e0 100644
--- a/tests/CommunityToolkit.Diagnostics.UnitTests/Extensions/Test_ValueTypeExtensions.cs
+++ b/tests/CommunityToolkit.Diagnostics.UnitTests/Extensions/Test_ValueTypeExtensions.cs
@@ -12,12 +12,12 @@ public class Test_ValueTypeExtensions
[TestMethod]
public void Test_ValueTypeExtensions_ToHexString()
{
- Assert.AreEqual(((byte)0).ToHexString(), "0x00");
- Assert.AreEqual(((byte)127).ToHexString(), "0x7F");
- Assert.AreEqual(((byte)255).ToHexString(), "0xFF");
- Assert.AreEqual(((ushort)6458).ToHexString(), "0x193A");
- Assert.AreEqual(6458.ToHexString(), "0x0000193A");
- Assert.AreEqual((-1).ToHexString(), "0xFFFFFFFF");
- Assert.AreEqual(true.ToHexString(), "0x01");
+ Assert.AreEqual("0x00", ((byte)0).ToHexString());
+ Assert.AreEqual("0x7F", ((byte)127).ToHexString());
+ Assert.AreEqual("0xFF", ((byte)255).ToHexString());
+ Assert.AreEqual("0x193A", ((ushort)6458).ToHexString());
+ Assert.AreEqual("0x0000193A", 6458.ToHexString());
+ Assert.AreEqual("0xFFFFFFFF", (-1).ToHexString());
+ Assert.AreEqual("0x01", true.ToHexString());
}
}
diff --git a/tests/CommunityToolkit.Diagnostics.UnitTests/Test_Guard.cs b/tests/CommunityToolkit.Diagnostics.UnitTests/Test_Guard.cs
index 7cbe156a9..4d4347d75 100644
--- a/tests/CommunityToolkit.Diagnostics.UnitTests/Test_Guard.cs
+++ b/tests/CommunityToolkit.Diagnostics.UnitTests/Test_Guard.cs
@@ -351,7 +351,7 @@ public void Test_Guard_IsTrue_Fail_WithMessage()
}
catch (ArgumentException e)
{
- Assert.IsTrue(e.Message.Contains("\"Hello world\""));
+ Assert.Contains("\"Hello world\"", e.Message);
return;
}
@@ -377,7 +377,7 @@ public void Test_Guard_IsTrue_WithHandler_Fail()
}
catch (ArgumentException e)
{
- Assert.IsTrue(e.Message.Contains($"This is an interpolated message: {DateTime.Now.Year}, {"hello".AsSpan()}"));
+ Assert.Contains($"This is an interpolated message: {DateTime.Now.Year}, {"hello".AsSpan()}", e.Message);
return;
}
@@ -410,7 +410,7 @@ public void Test_Guard_IsFalse_Fail_WithMessage()
}
catch (ArgumentException e)
{
- Assert.IsTrue(e.Message.Contains("\"Hello world\""));
+ Assert.Contains("\"Hello world\"", e.Message);
return;
}
@@ -434,7 +434,7 @@ public void Test_Guard_IsFalse_WithHandler_Fail()
}
catch (ArgumentException e)
{
- Assert.IsTrue(e.Message.Contains($"This is an interpolated message: {DateTime.Now.Year}, {"hello".AsSpan()}"));
+ Assert.Contains($"This is an interpolated message: {DateTime.Now.Year}, {"hello".AsSpan()}", e.Message);
return;
}
@@ -731,7 +731,7 @@ public void Test_Guard_CallerArgumentExpression_1()
}
catch (ArgumentNullException e)
{
- Assert.AreEqual(e.ParamName, nameof(thisStringShouldNotBeNull));
+ Assert.AreEqual(nameof(thisStringShouldNotBeNull), e.ParamName);
return;
}
@@ -751,7 +751,7 @@ public void Test_Guard_CallerArgumentExpression_2()
}
catch (ArgumentOutOfRangeException e)
{
- Assert.AreEqual(e.ParamName, nameof(thisIndexIsOutOfRange));
+ Assert.AreEqual(nameof(thisIndexIsOutOfRange), e.ParamName);
return;
}
@@ -771,7 +771,7 @@ public void Test_Guard_CallerArgumentExpression_3()
}
catch (ArgumentException e)
{
- Assert.AreEqual(e.ParamName, nameof(thisArrayShouldNotBeShorterThan10));
+ Assert.AreEqual(nameof(thisArrayShouldNotBeShorterThan10), e.ParamName);
return;
}
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_ArrayPoolBufferWriter{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_ArrayPoolBufferWriter{T}.cs
index 7c4e40015..8126c834f 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_ArrayPoolBufferWriter{T}.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_ArrayPoolBufferWriter{T}.cs
@@ -52,7 +52,7 @@ public void Test_ArrayPoolBufferWriterOfT_BufferSize(int request, int expected)
byte[] array = (byte[])arrayFieldInfo!.GetValue(writer)!;
- Assert.AreEqual(array.Length, expected);
+ Assert.HasCount(expected, array);
}
[TestMethod]
@@ -60,23 +60,23 @@ public void Test_ArrayPoolBufferWriterOfT_AllocateAndGetMemoryAndSpan()
{
ArrayPoolBufferWriter? writer = new();
- Assert.AreEqual(writer.Capacity, 256);
- Assert.AreEqual(writer.FreeCapacity, 256);
- Assert.AreEqual(writer.WrittenCount, 0);
+ Assert.AreEqual(256, writer.Capacity);
+ Assert.AreEqual(256, writer.FreeCapacity);
+ Assert.AreEqual(0, writer.WrittenCount);
Assert.IsTrue(writer.WrittenMemory.IsEmpty);
Assert.IsTrue(writer.WrittenSpan.IsEmpty);
Span span = writer.GetSpan(43);
- Assert.IsTrue(span.Length >= 43);
+ Assert.IsGreaterThanOrEqualTo(43, span.Length);
writer.Advance(43);
- Assert.AreEqual(writer.Capacity, 256);
- Assert.AreEqual(writer.FreeCapacity, 256 - 43);
- Assert.AreEqual(writer.WrittenCount, 43);
- Assert.AreEqual(writer.WrittenMemory.Length, 43);
- Assert.AreEqual(writer.WrittenSpan.Length, 43);
+ Assert.AreEqual(256, writer.Capacity);
+ Assert.AreEqual(256 - 43, writer.FreeCapacity);
+ Assert.AreEqual(43, writer.WrittenCount);
+ Assert.AreEqual(43, writer.WrittenMemory.Length);
+ Assert.AreEqual(43, writer.WrittenSpan.Length);
_ = Assert.ThrowsExactly(() => writer.Advance(-1));
_ = Assert.ThrowsExactly(() => writer.GetMemory(-1));
@@ -99,25 +99,25 @@ public void Test_ArrayPoolBufferWriterOfT_AllocateFromCustomPoolAndGetMemoryAndS
using (ArrayPoolBufferWriter? writer = new(pool))
{
- Assert.AreEqual(pool.RentedArrays.Count, 1);
+ Assert.HasCount(1, pool.RentedArrays);
- Assert.AreEqual(writer.Capacity, 256);
- Assert.AreEqual(writer.FreeCapacity, 256);
- Assert.AreEqual(writer.WrittenCount, 0);
+ Assert.AreEqual(256, writer.Capacity);
+ Assert.AreEqual(256, writer.FreeCapacity);
+ Assert.AreEqual(0, writer.WrittenCount);
Assert.IsTrue(writer.WrittenMemory.IsEmpty);
Assert.IsTrue(writer.WrittenSpan.IsEmpty);
Span span = writer.GetSpan(43);
- Assert.IsTrue(span.Length >= 43);
+ Assert.IsGreaterThanOrEqualTo(43, span.Length);
writer.Advance(43);
- Assert.AreEqual(writer.Capacity, 256);
- Assert.AreEqual(writer.FreeCapacity, 256 - 43);
- Assert.AreEqual(writer.WrittenCount, 43);
- Assert.AreEqual(writer.WrittenMemory.Length, 43);
- Assert.AreEqual(writer.WrittenSpan.Length, 43);
+ Assert.AreEqual(256, writer.Capacity);
+ Assert.AreEqual(256 - 43, writer.FreeCapacity);
+ Assert.AreEqual(43, writer.WrittenCount);
+ Assert.AreEqual(43, writer.WrittenMemory.Length);
+ Assert.AreEqual(43, writer.WrittenSpan.Length);
_ = Assert.ThrowsExactly(() => writer.Advance(-1));
_ = Assert.ThrowsExactly(() => writer.GetMemory(-1));
@@ -133,7 +133,7 @@ public void Test_ArrayPoolBufferWriterOfT_AllocateFromCustomPoolAndGetMemoryAndS
_ = Assert.ThrowsExactly(() => writer.Advance(1));
}
- Assert.AreEqual(pool.RentedArrays.Count, 0);
+ Assert.IsEmpty(pool.RentedArrays);
}
[TestMethod]
@@ -155,12 +155,12 @@ public void Test_ArrayPoolBufferWriterOfT_Clear()
writer.Advance(4);
- Assert.AreEqual(writer.WrittenCount, 4);
+ Assert.AreEqual(4, writer.WrittenCount);
Assert.IsTrue(span.SequenceEqual(data));
writer.Clear();
- Assert.AreEqual(writer.WrittenCount, 0);
+ Assert.AreEqual(0, writer.WrittenCount);
Assert.IsTrue(span.ToArray().All(b => b == 0));
}
@@ -191,13 +191,13 @@ public void Test_ArrayPoolBufferWriterOfT_AsStream()
writeStream.Write(guid);
}
- Assert.AreEqual(writer.WrittenCount, GuidSize);
+ Assert.AreEqual(GuidSize, writer.WrittenCount);
// Here we get a readable stream instead, and read from it to ensure
// the previous data was written correctly from the writeable stream.
using (Stream stream = writer.WrittenMemory.AsStream())
{
- Assert.AreEqual(stream.Length, GuidSize);
+ Assert.AreEqual(GuidSize, stream.Length);
byte[] result = new byte[GuidSize];
@@ -230,8 +230,8 @@ public void Test_ArrayPoolBufferWriterOfT_AllocateAndGetArray()
ArraySegment segment = bufferWriter.DangerousGetArray();
Assert.IsNotNull(segment.Array);
- Assert.IsTrue(segment.Array.Length >= bufferWriter.WrittenSpan.Length);
- Assert.AreEqual(segment.Offset, 0);
+ Assert.IsGreaterThanOrEqualTo(bufferWriter.WrittenSpan.Length, segment.Array.Length);
+ Assert.AreEqual(0, segment.Offset);
Assert.AreEqual(segment.Count, bufferWriter.WrittenSpan.Length);
_ = MemoryMarshal.TryGetArray(bufferWriter.WrittenMemory, out ArraySegment writtenSegment);
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_MemoryBufferWriter{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_MemoryBufferWriter{T}.cs
index bc0eb6740..6f78ab823 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_MemoryBufferWriter{T}.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_MemoryBufferWriter{T}.cs
@@ -19,9 +19,9 @@ public void Test_MemoryBufferWriterOfT_AllocateAndGetMemoryAndSpan()
MemoryBufferWriter? writer = new(memory);
- Assert.AreEqual(writer.Capacity, 256);
- Assert.AreEqual(writer.FreeCapacity, 256);
- Assert.AreEqual(writer.WrittenCount, 0);
+ Assert.AreEqual(256, writer.Capacity);
+ Assert.AreEqual(256, writer.FreeCapacity);
+ Assert.AreEqual(0, writer.WrittenCount);
Assert.IsTrue(writer.WrittenMemory.IsEmpty);
Assert.IsTrue(writer.WrittenSpan.IsEmpty);
@@ -31,11 +31,11 @@ public void Test_MemoryBufferWriterOfT_AllocateAndGetMemoryAndSpan()
writer.Advance(43);
- Assert.AreEqual(writer.Capacity, 256);
- Assert.AreEqual(writer.FreeCapacity, 256 - 43);
- Assert.AreEqual(writer.WrittenCount, 43);
- Assert.AreEqual(writer.WrittenMemory.Length, 43);
- Assert.AreEqual(writer.WrittenSpan.Length, 43);
+ Assert.AreEqual(256, writer.Capacity);
+ Assert.AreEqual(256 - 43, writer.FreeCapacity);
+ Assert.AreEqual(43, writer.WrittenCount);
+ Assert.AreEqual(43, writer.WrittenMemory.Length);
+ Assert.AreEqual(43, writer.WrittenSpan.Length);
Assert.AreEqual(memory.Length - 43, writer.GetSpan().Length);
Assert.AreEqual(memory.Length - 43, writer.GetMemory().Length);
@@ -64,12 +64,12 @@ public void Test_MemoryBufferWriterOfT_Clear()
writer.Advance(4);
- Assert.AreEqual(writer.WrittenCount, 4);
+ Assert.AreEqual(4, writer.WrittenCount);
Assert.IsTrue(span.SequenceEqual(data));
writer.Clear();
- Assert.AreEqual(writer.WrittenCount, 0);
+ Assert.AreEqual(0, writer.WrittenCount);
Assert.IsTrue(span.ToArray().All(b => b == 0));
}
}
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_MemoryOwner{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_MemoryOwner{T}.cs
index f256557e5..91216120d 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_MemoryOwner{T}.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_MemoryOwner{T}.cs
@@ -18,9 +18,9 @@ public void Test_MemoryOwnerOfT_AllocateAndGetMemoryAndSpan()
{
using MemoryOwner? buffer = MemoryOwner.Allocate(127);
- Assert.IsTrue(buffer.Length == 127);
- Assert.IsTrue(buffer.Memory.Length == 127);
- Assert.IsTrue(buffer.Span.Length == 127);
+ Assert.AreEqual(127, buffer.Length);
+ Assert.AreEqual(127, buffer.Memory.Length);
+ Assert.AreEqual(127, buffer.Span.Length);
buffer.Span.Fill(42);
@@ -35,11 +35,11 @@ public void Test_MemoryOwnerOfT_AllocateFromCustomPoolAndGetMemoryAndSpan()
using (MemoryOwner? buffer = MemoryOwner.Allocate(127, pool))
{
- Assert.AreEqual(pool.RentedArrays.Count, 1);
+ Assert.HasCount(1, pool.RentedArrays);
- Assert.IsTrue(buffer.Length == 127);
- Assert.IsTrue(buffer.Memory.Length == 127);
- Assert.IsTrue(buffer.Span.Length == 127);
+ Assert.AreEqual(127, buffer.Length);
+ Assert.AreEqual(127, buffer.Memory.Length);
+ Assert.AreEqual(127, buffer.Span.Length);
buffer.Span.Fill(42);
@@ -47,7 +47,7 @@ public void Test_MemoryOwnerOfT_AllocateFromCustomPoolAndGetMemoryAndSpan()
Assert.IsTrue(buffer.Span.ToArray().All(i => i == 42));
}
- Assert.AreEqual(pool.RentedArrays.Count, 0);
+ Assert.IsEmpty(pool.RentedArrays);
}
[TestMethod]
@@ -127,8 +127,8 @@ public void Test_MemoryOwnerOfT_AllocateAndGetArray()
ArraySegment segment = buffer.DangerousGetArray();
Assert.IsNotNull(segment.Array);
- Assert.IsTrue(segment.Array.Length >= buffer.Length);
- Assert.AreEqual(segment.Offset, 0);
+ Assert.IsGreaterThanOrEqualTo(buffer.Length, segment.Array.Length);
+ Assert.AreEqual(0, segment.Offset);
Assert.AreEqual(segment.Count, buffer.Length);
MemoryOwner? second = buffer.Slice(10, 80);
@@ -142,8 +142,8 @@ public void Test_MemoryOwnerOfT_AllocateAndGetArray()
// Same as before, but we now also verify the initial offset != 0, as we used Slice
Assert.IsNotNull(segment.Array);
- Assert.IsTrue(segment.Array.Length >= second.Length);
- Assert.AreEqual(segment.Offset, 10);
+ Assert.IsGreaterThanOrEqualTo(second.Length, segment.Array.Length);
+ Assert.AreEqual(10, segment.Offset);
Assert.AreEqual(segment.Count, second.Length);
second.Dispose();
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_SpanOwner{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_SpanOwner{T}.cs
index 3ba918805..a8ff3cb8b 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_SpanOwner{T}.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_SpanOwner{T}.cs
@@ -18,8 +18,8 @@ public void Test_SpanOwnerOfT_AllocateAndGetMemoryAndSpan()
{
using SpanOwner buffer = SpanOwner.Allocate(127);
- Assert.IsTrue(buffer.Length == 127);
- Assert.IsTrue(buffer.Span.Length == 127);
+ Assert.AreEqual(127, buffer.Length);
+ Assert.AreEqual(127, buffer.Span.Length);
buffer.Span.Fill(42);
@@ -33,17 +33,17 @@ public void Test_SpanOwnerOfT_AllocateFromCustomPoolAndGetMemoryAndSpan()
using (SpanOwner buffer = SpanOwner.Allocate(127, pool))
{
- Assert.AreEqual(pool.RentedArrays.Count, 1);
+ Assert.HasCount(1, pool.RentedArrays);
- Assert.IsTrue(buffer.Length == 127);
- Assert.IsTrue(buffer.Span.Length == 127);
+ Assert.AreEqual(127, buffer.Length);
+ Assert.AreEqual(127, buffer.Span.Length);
buffer.Span.Fill(42);
Assert.IsTrue(buffer.Span.ToArray().All(i => i == 42));
}
- Assert.AreEqual(pool.RentedArrays.Count, 0);
+ Assert.IsEmpty(pool.RentedArrays);
}
[TestMethod]
@@ -86,8 +86,8 @@ public void Test_SpanOwnerOfT_AllocateAndGetArray()
// with the assumption that usages after dispose are undefined behavior. This
// is all documented in the XML docs for the SpanOwner type.
Assert.IsNotNull(segment.Array);
- Assert.IsTrue(segment.Array.Length >= buffer.Length);
- Assert.AreEqual(segment.Offset, 0);
+ Assert.IsGreaterThanOrEqualTo(buffer.Length, segment.Array.Length);
+ Assert.AreEqual(0, segment.Offset);
Assert.AreEqual(segment.Count, buffer.Length);
}
}
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_StringPool.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_StringPool.cs
index 08a3715a8..c9140c49d 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_StringPool.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_StringPool.cs
@@ -37,13 +37,13 @@ public void Test_StringPool_Cctor_Ok(int minimumSize, int x, int y, int size)
Array maps = (Array)typeof(StringPool).GetField("maps", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(pool)!;
- Assert.AreEqual(x, maps.Length);
+ Assert.HasCount(x, maps);
Type bucketType = Type.GetType("CommunityToolkit.HighPerformance.Buffers.StringPool+FixedSizePriorityMap, CommunityToolkit.HighPerformance")!;
int[] buckets = (int[])bucketType.GetField("buckets", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(maps.GetValue(0))!;
- Assert.AreEqual(y, buckets.Length);
+ Assert.HasCount(y, buckets);
}
[TestMethod]
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj b/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj
index 6614792ac..a4fc36d66 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj
@@ -11,8 +11,8 @@
-
-
+
+
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ArrayExtensions.2D.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ArrayExtensions.2D.cs
index d6d5bf8e3..8a2102cdb 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ArrayExtensions.2D.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ArrayExtensions.2D.cs
@@ -428,7 +428,7 @@ public void Test_ArrayExtensions_2D_AsSpan_Empty()
Span span = array.AsSpan();
// Check that the empty array was loaded properly
- Assert.AreEqual(span.Length, array.Length);
+ Assert.HasCount(span.Length, array);
Assert.IsTrue(span.IsEmpty);
}
@@ -445,7 +445,7 @@ public void Test_ArrayExtensions_2D_AsSpan_Populated()
Span span = array.AsSpan();
// Test the total length of the span
- Assert.AreEqual(span.Length, array.Length);
+ Assert.HasCount(span.Length, array);
ref int r0 = ref array[0, 0];
ref int r1 = ref span[0];
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ArrayPoolExtensions.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ArrayPoolExtensions.cs
index c31fe6817..14b0815fd 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ArrayPoolExtensions.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ArrayPoolExtensions.cs
@@ -29,7 +29,7 @@ public void Test_ArrayPoolExtensions_Resize_NewArray()
ArrayPool.Shared.Resize(ref array, 10);
Assert.IsNotNull(array);
- Assert.IsTrue(array.Length >= 10);
+ Assert.IsGreaterThanOrEqualTo(10, array.Length);
}
[TestMethod]
@@ -54,7 +54,7 @@ public void Test_ArrayPoolExtensions_Resize_Expand()
ArrayPool.Shared.Resize(ref array, 32);
Assert.AreNotSame(array, backup);
- Assert.IsTrue(array.Length >= 32);
+ Assert.IsGreaterThanOrEqualTo(32, array.Length);
Assert.IsTrue(array.AsSpan(0, 16).ToArray().All(i => i == 7));
}
@@ -69,7 +69,7 @@ public void Test_ArrayPoolExtensions_Resize_Shrink()
ArrayPool.Shared.Resize(ref array, 16);
Assert.AreNotSame(array, backup);
- Assert.IsTrue(array.Length >= 16);
+ Assert.IsGreaterThanOrEqualTo(16, array.Length);
Assert.IsTrue(array.AsSpan(0, 16).ToArray().All(i => i == 7));
}
@@ -103,7 +103,7 @@ public void Test_ArrayPoolExtensions_EnsureCapacity_IdenticalCapacity()
ArrayPool.Shared.EnsureCapacity(ref array, 10);
Assert.AreSame(backup, array);
- Assert.IsTrue(array.Length >= 10);
+ Assert.IsGreaterThanOrEqualTo(10, array.Length);
}
[TestMethod]
@@ -114,13 +114,13 @@ public void Test_ArrayPoolExtensions_EnsureCapacity_NewArray()
ArrayPool.Shared.EnsureCapacity(ref array, 7);
Assert.IsNotNull(array);
- Assert.IsTrue(array.Length >= 7);
+ Assert.IsGreaterThanOrEqualTo(7, array.Length);
int[]? backup = array;
ArrayPool.Shared.EnsureCapacity(ref array, 64);
Assert.AreNotSame(backup, array);
- Assert.IsTrue(array.Length >= 64);
+ Assert.IsGreaterThanOrEqualTo(64, array.Length);
}
[TestMethod]
@@ -152,6 +152,6 @@ public void Test_ArrayPoolExtensions_EnsureCapacity_ClearArray()
Assert.AreNotSame(backup, array);
Assert.IsTrue(backup.All(i => i == default));
- Assert.IsTrue(array.Length >= 256);
+ Assert.IsGreaterThanOrEqualTo(256, array.Length);
}
}
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_IMemoryOwnerExtensions.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_IMemoryOwnerExtensions.cs
index 42db952ca..d6673ae3b 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_IMemoryOwnerExtensions.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_IMemoryOwnerExtensions.cs
@@ -19,8 +19,8 @@ public void Test_IMemoryOwnerExtensions_EmptyIMemoryOwnerStream()
Stream stream = buffer.AsStream();
Assert.IsNotNull(stream);
- Assert.AreEqual(buffer.Length, 0);
- Assert.AreEqual(stream.Length, 0);
+ Assert.AreEqual(0, buffer.Length);
+ Assert.AreEqual(0, stream.Length);
Assert.IsTrue(stream.CanWrite);
}
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_MemoryExtensions.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_MemoryExtensions.cs
index 849bde106..3e19995f7 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_MemoryExtensions.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_MemoryExtensions.cs
@@ -61,13 +61,13 @@ public void Test_MemoryExtensions_Cast_TooShort()
Memory m2 = new byte[13];
Memory mc2 = m2.Cast();
- Assert.AreEqual(mc2.Length, 3);
+ Assert.AreEqual(3, mc2.Length);
// 16 - 5 = 11 ---> 11 / sizeof(int) = 2
Memory m3 = new byte[16].AsMemory(5);
Memory mc3 = m3.Cast();
- Assert.AreEqual(mc3.Length, 2);
+ Assert.AreEqual(2, mc3.Length);
}
[TestMethod]
@@ -77,7 +77,7 @@ public void Test_MemoryExtensions_FromArray_CastFromByte()
Memory memoryOfBytes = new byte[128];
Memory memoryOfFloats = memoryOfBytes.Cast();
- Assert.AreEqual(memoryOfFloats.Length, 128 / sizeof(float));
+ Assert.AreEqual(128 / sizeof(float), memoryOfFloats.Length);
Span spanOfBytes = memoryOfBytes.Span;
Span spanOfFloats = memoryOfFloats.Span;
@@ -99,7 +99,7 @@ public void Test_MemoryExtensions_FromArray_CastToByte()
Memory memoryOfFloats = new float[128];
Memory memoryOfBytes = memoryOfFloats.Cast();
- Assert.AreEqual(memoryOfBytes.Length, 128 * sizeof(float));
+ Assert.AreEqual(128 * sizeof(float), memoryOfBytes.Length);
Span spanOfFloats = memoryOfFloats.Span;
Span spanOfBytes = memoryOfBytes.Span;
@@ -119,7 +119,7 @@ public void Test_MemoryExtensions_FromArray_CastToShort()
Memory memoryOfFloats = new float[128];
Memory memoryOfShorts = memoryOfFloats.Cast();
- Assert.AreEqual(memoryOfShorts.Length, 128 * sizeof(float) / sizeof(short));
+ Assert.AreEqual(128 * sizeof(float) / sizeof(short), memoryOfShorts.Length);
Span spanOfFloats = memoryOfFloats.Span;
Span spanOfShorts = memoryOfShorts.Span;
@@ -149,8 +149,8 @@ public void Test_MemoryExtensions_FromArray_CastFromByteAndBack()
// the associated parameters match the ones we'd expect here (same length, offset of 0).
Assert.IsTrue(MemoryMarshal.TryGetArray(memoryBack, out ArraySegment segment));
Assert.AreSame(segment.Array!, data);
- Assert.AreEqual(segment.Offset, 0);
- Assert.AreEqual(segment.Count, data.Length);
+ Assert.AreEqual(0, segment.Offset);
+ Assert.HasCount(segment.Count, data);
Assert.IsTrue(memoryOfBytes.Equals(memoryBack));
@@ -174,12 +174,12 @@ public void Test_MemoryExtensions_Cast_TooShort_WithSlice()
Memory m2 = new byte[20].AsMemory().Slice(4, 13);
Memory mc2 = m2.Cast();
- Assert.AreEqual(mc2.Length, 3);
+ Assert.AreEqual(3, mc2.Length);
Memory m3 = new byte[16].AsMemory().Slice(5);
Memory mc3 = m3.Cast();
- Assert.AreEqual(mc3.Length, 2);
+ Assert.AreEqual(2, mc3.Length);
}
[TestMethod]
@@ -190,7 +190,7 @@ public void Test_MemoryExtensions_FromArray_CastFromByte_WithSlice()
Memory memoryOfBytes = new byte[512].AsMemory().Slice(128, 128);
Memory memoryOfFloats = memoryOfBytes.Cast();
- Assert.AreEqual(memoryOfFloats.Length, 128 / sizeof(float));
+ Assert.AreEqual(128 / sizeof(float), memoryOfFloats.Length);
Span spanOfBytes = memoryOfBytes.Span;
Span spanOfFloats = memoryOfFloats.Span;
@@ -208,7 +208,7 @@ public void Test_MemoryExtensions_FromArray_CastToByte_WithSlice()
Memory memoryOfFloats = new float[512].AsMemory().Slice(128, 128);
Memory memoryOfBytes = memoryOfFloats.Cast();
- Assert.AreEqual(memoryOfBytes.Length, 128 * sizeof(float));
+ Assert.AreEqual(128 * sizeof(float), memoryOfBytes.Length);
Span spanOfFloats = memoryOfFloats.Span;
Span spanOfBytes = memoryOfBytes.Span;
@@ -227,7 +227,7 @@ public void Test_MemoryExtensions_FromArray_CastToShort_WithSlice()
Memory memoryOfFloats = new float[512].AsMemory().Slice(128, 128);
Memory memoryOfShorts = memoryOfFloats.Cast();
- Assert.AreEqual(memoryOfShorts.Length, 128 * sizeof(float) / sizeof(short));
+ Assert.AreEqual(128 * sizeof(float) / sizeof(short), memoryOfShorts.Length);
Span spanOfFloats = memoryOfFloats.Span;
Span spanOfShorts = memoryOfShorts.Span;
@@ -252,8 +252,8 @@ public void Test_MemoryExtensions_FromArray_CastFromByteAndBack_WithSlice()
// Here we now also have to validate the starting offset from the extracted array
Assert.IsTrue(MemoryMarshal.TryGetArray(memoryBack, out ArraySegment segment));
Assert.AreSame(segment.Array!, data);
- Assert.AreEqual(segment.Offset, 128);
- Assert.AreEqual(segment.Count, 128);
+ Assert.AreEqual(128, segment.Offset);
+ Assert.HasCount(128, segment);
Assert.IsTrue(memoryOfBytes.Equals(memoryBack));
@@ -273,7 +273,7 @@ public void Test_MemoryExtensions_FromMemoryManager_CastFromByte()
Memory memoryOfBytes = new ArrayMemoryManager(128);
Memory memoryOfFloats = memoryOfBytes.Cast();
- Assert.AreEqual(memoryOfFloats.Length, 128 / sizeof(float));
+ Assert.AreEqual(128 / sizeof(float), memoryOfFloats.Length);
Span spanOfBytes = memoryOfBytes.Span;
Span spanOfFloats = memoryOfFloats.Span;
@@ -291,7 +291,7 @@ public void Test_MemoryExtensions_FromMemoryManager_CastToByte()
Memory memoryOfFloats = new ArrayMemoryManager(128);
Memory memoryOfBytes = memoryOfFloats.Cast();
- Assert.AreEqual(memoryOfBytes.Length, 128 * sizeof(float));
+ Assert.AreEqual(128 * sizeof(float), memoryOfBytes.Length);
Span spanOfFloats = memoryOfFloats.Span;
Span spanOfBytes = memoryOfBytes.Span;
@@ -309,7 +309,7 @@ public void Test_MemoryExtensions_FromMemoryManager_CastToShort()
Memory memoryOfFloats = new ArrayMemoryManager(128);
Memory memoryOfShorts = memoryOfFloats.Cast();
- Assert.AreEqual(memoryOfShorts.Length, 128 * sizeof(float) / sizeof(short));
+ Assert.AreEqual(128 * sizeof(float) / sizeof(short), memoryOfShorts.Length);
Span spanOfFloats = memoryOfFloats.Span;
Span spanOfShorts = memoryOfShorts.Span;
@@ -335,8 +335,8 @@ public void Test_MemoryExtensions_FromMemoryManager_CastFromByteAndBack()
// checked for when using an array. We need to check they're the same, and the other parameters.
Assert.IsTrue(MemoryMarshal.TryGetMemoryManager>(memoryBack, out ArrayMemoryManager? manager, out int start, out int length));
Assert.AreSame(manager!, data);
- Assert.AreEqual(start, 0);
- Assert.AreEqual(length, 128);
+ Assert.AreEqual(0, start);
+ Assert.AreEqual(128, length);
Assert.IsTrue(memoryOfBytes.Equals(memoryBack));
@@ -353,7 +353,7 @@ public void Test_MemoryExtensions_FromMemoryManager_CastFromByte_WithSlice()
Memory memoryOfBytes = new ArrayMemoryManager(512).Memory.Slice(128, 128);
Memory memoryOfFloats = memoryOfBytes.Cast();
- Assert.AreEqual(memoryOfFloats.Length, 128 / sizeof(float));
+ Assert.AreEqual(128 / sizeof(float), memoryOfFloats.Length);
Span spanOfBytes = memoryOfBytes.Span;
Span spanOfFloats = memoryOfFloats.Span;
@@ -371,7 +371,7 @@ public void Test_MemoryExtensions_FromMemoryManager_CastToByte_WithSlice()
Memory memoryOfFloats = new ArrayMemoryManager(512).Memory.Slice(128, 128);
Memory memoryOfBytes = memoryOfFloats.Cast();
- Assert.AreEqual(memoryOfBytes.Length, 128 * sizeof(float));
+ Assert.AreEqual(128 * sizeof(float), memoryOfBytes.Length);
Span spanOfFloats = memoryOfFloats.Span;
Span spanOfBytes = memoryOfBytes.Span;
@@ -389,7 +389,7 @@ public void Test_MemoryExtensions_FromMemoryManager_CastToShort_WithSlice()
Memory memoryOfFloats = new ArrayMemoryManager(512).Memory.Slice(128, 128);
Memory memoryOfShorts = memoryOfFloats.Cast();
- Assert.AreEqual(memoryOfShorts.Length, 128 * sizeof(float) / sizeof(short));
+ Assert.AreEqual(128 * sizeof(float) / sizeof(short), memoryOfShorts.Length);
Span spanOfFloats = memoryOfFloats.Span;
Span spanOfShorts = memoryOfShorts.Span;
@@ -414,8 +414,8 @@ public void Test_MemoryExtensions_FromMemoryManager_CastFromByteAndBack_WithSlic
// Here we also need to validate that the offset was maintained
Assert.IsTrue(MemoryMarshal.TryGetMemoryManager>(memoryBack, out ArrayMemoryManager? manager, out int start, out int length));
Assert.AreSame(manager!, data);
- Assert.AreEqual(start, 128);
- Assert.AreEqual(length, 128);
+ Assert.AreEqual(128, start);
+ Assert.AreEqual(128, length);
Assert.IsTrue(memoryOfBytes.Equals(memoryBack));
@@ -493,7 +493,7 @@ public void Test_MemoryExtensions_FromString_CastFromByteAndBack()
// Get the original string back (to validate the optimization too) and check the params
Assert.IsTrue(MemoryMarshal.TryGetString(memoryOfChars, out string? text, out int start, out int length));
Assert.AreSame(text!, data);
- Assert.AreEqual(start, 0);
+ Assert.AreEqual(0, start);
Assert.AreEqual(length, data.Length);
Assert.IsTrue(memoryOfChars.Equals(memoryBack));
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ReadOnlySpanExtensions.Count.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ReadOnlySpanExtensions.Count.cs
index 346e801f9..e43417745 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ReadOnlySpanExtensions.Count.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ReadOnlySpanExtensions.Count.cs
@@ -89,7 +89,7 @@ public void Test_ReadOnlySpanExtensions_RandomCountManaged()
int result = data.Count(value);
int expected = CountWithForeach(data, value);
- Assert.AreEqual(result, expected, $"Failed {typeof(Int)} test with count {count}: got {result} instead of {expected}");
+ Assert.AreEqual(expected, result, $"Failed {typeof(Int)} test with count {count}: got {result} instead of {expected}");
}
}
@@ -181,7 +181,7 @@ private static void TestForType(T value, Func>
int result = data.GetSpan().Count(value);
int expected = CountWithForeach(data.GetSpan(), value);
- Assert.AreEqual(result, expected, $"Failed {typeof(T)} test with count {count}: got {result} instead of {expected}");
+ Assert.AreEqual(expected, result, $"Failed {typeof(T)} test with count {count}: got {result} instead of {expected}");
}
}
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_SpinLockExtensions.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_SpinLockExtensions.cs
index 50b5d288a..8838e8bc6 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_SpinLockExtensions.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_SpinLockExtensions.cs
@@ -32,7 +32,7 @@ public unsafe void Test_ArrayExtensions_Pointer()
}
});
- Assert.AreEqual(sum, 1000 * 10);
+ Assert.AreEqual(1000 * 10, sum);
}
#if NET8_0_OR_GREATER
@@ -54,7 +54,7 @@ public void Test_ArrayExtensions_Ref()
}
});
- Assert.AreEqual(sum, 1000 * 10);
+ Assert.AreEqual(1000 * 10, sum);
}
///
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_StreamExtensions.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_StreamExtensions.cs
index 3664d49c3..30580d08b 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_StreamExtensions.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_StreamExtensions.cs
@@ -23,13 +23,13 @@ public void Test_StreamExtensions_ReadWrite()
stream.Write(3.14f);
stream.Write(unchecked(uint.MaxValue * 324823489204ul));
- Assert.AreEqual(stream.Position, 17);
+ Assert.AreEqual(17, stream.Position);
_ = Assert.ThrowsExactly(() => stream.Write(long.MaxValue));
stream.Position = 0;
- Assert.AreEqual(true, stream.Read());
+ Assert.IsTrue(stream.Read());
Assert.AreEqual(42, stream.Read());
Assert.AreEqual(3.14f, stream.Read());
Assert.AreEqual(unchecked(uint.MaxValue * 324823489204ul), stream.Read());
@@ -50,7 +50,7 @@ public void Test_StreamExtensions_ReadWrite_WithBufferedStream()
stream.Position = 0;
- Assert.AreEqual(true, stream.Read());
+ Assert.IsTrue(stream.Read());
Assert.AreEqual(42, stream.Read());
Assert.AreEqual(3.14f, stream.Read());
Assert.AreEqual(unchecked(uint.MaxValue * 324823489204ul), stream.Read());
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_BitHelper.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_BitHelper.cs
index 3df976c4e..25b8a52ee 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_BitHelper.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_BitHelper.cs
@@ -194,7 +194,7 @@ public void Test_BitHelper_SetRange_UInt32(byte start, byte length, uint flags)
uint restored = BitHelper.SetRange(result, start, length, backup);
Assert.AreEqual(extracted, flags);
- Assert.AreEqual(restored, value);
+ Assert.AreEqual(value, restored);
}
[TestMethod]
@@ -302,6 +302,6 @@ public void Test_BitHelper_SetRange_UInt64(byte start, byte length, ulong flags)
ulong restored = BitHelper.SetRange(result, start, length, backup);
Assert.AreEqual(extracted, flags);
- Assert.AreEqual(restored, value);
+ Assert.AreEqual(value, restored);
}
}
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ObjectMarshal.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ObjectMarshal.cs
index 924bdc6bb..89e344406 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ObjectMarshal.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ObjectMarshal.cs
@@ -107,7 +107,7 @@ private static void Test(T value)
success = obj.TryUnbox(out decimal test);
Assert.IsFalse(success);
- Assert.AreEqual(test, default);
+ Assert.AreEqual(default, test);
result = ObjectMarshal.DangerousUnbox(obj);
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.ForEach.In.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.ForEach.In.cs
index 4c393c210..f9755a8a8 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.ForEach.In.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.ForEach.In.cs
@@ -31,7 +31,7 @@ public unsafe void Test_ParallelHelper_ForEach_In()
expected += n;
}
- Assert.AreEqual(sum, expected, $"The sum doesn't match, was {sum} instead of {expected}");
+ Assert.AreEqual(expected, sum, $"The sum doesn't match, was {sum} instead of {expected}");
}
}
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.ForEach.In2D.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.ForEach.In2D.cs
index 734377225..bf7d798fe 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.ForEach.In2D.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.ForEach.In2D.cs
@@ -50,7 +50,7 @@ public unsafe void Test_ParallelHelper_ForEach_In2D(
expected += n;
}
- Assert.AreEqual(sum, expected, $"The sum doesn't match, was {sum} instead of {expected}");
+ Assert.AreEqual(expected, sum, $"The sum doesn't match, was {sum} instead of {expected}");
}
///
diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_Memory2D{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_Memory2D{T}.cs
index 399556c2d..d1ed6cdad 100644
--- a/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_Memory2D{T}.cs
+++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_Memory2D{T}.cs
@@ -19,30 +19,30 @@ public void Test_Memory2DT_Empty()
Memory2D empty1 = default;
Assert.IsTrue(empty1.IsEmpty);
- Assert.AreEqual(empty1.Length, 0);
- Assert.AreEqual(empty1.Width, 0);
- Assert.AreEqual(empty1.Height, 0);
+ Assert.AreEqual(0, empty1.Length);
+ Assert.AreEqual(0, empty1.Width);
+ Assert.AreEqual(0, empty1.Height);
Memory2D empty2 = Memory2D.Empty;
Assert.IsTrue(empty2.IsEmpty);
- Assert.AreEqual(empty2.Length, 0);
- Assert.AreEqual(empty2.Width, 0);
- Assert.AreEqual(empty2.Height, 0);
+ Assert.AreEqual(0, empty2.Length);
+ Assert.AreEqual(0, empty2.Width);
+ Assert.AreEqual(0, empty2.Height);
Memory2D empty3 = new int[4, 0];
Assert.IsTrue(empty3.IsEmpty);
- Assert.AreEqual(empty3.Length, 0);
- Assert.AreEqual(empty3.Width, 0);
- Assert.AreEqual(empty3.Height, 4);
+ Assert.AreEqual(0, empty3.Length);
+ Assert.AreEqual(0, empty3.Width);
+ Assert.AreEqual(4, empty3.Height);
Memory2D empty4 = new int[0, 7];
Assert.IsTrue(empty4.IsEmpty);
- Assert.AreEqual(empty4.Length, 0);
- Assert.AreEqual(empty4.Width, 7);
- Assert.AreEqual(empty4.Height, 0);
+ Assert.AreEqual(0, empty4.Length);
+ Assert.AreEqual(7, empty4.Width);
+ Assert.AreEqual(0, empty4.Height);
}
[TestMethod]
@@ -58,11 +58,11 @@ public void Test_Memory2DT_Array1DConstructor()
Memory2D memory2d = new(array, 1, 2, 2, 1);
Assert.IsFalse(memory2d.IsEmpty);
- Assert.AreEqual(memory2d.Length, 4);
- Assert.AreEqual(memory2d.Width, 2);
- Assert.AreEqual(memory2d.Height, 2);
- Assert.AreEqual(memory2d.Span[0, 0], 2);
- Assert.AreEqual(memory2d.Span[1, 1], 6);
+ Assert.AreEqual(4, memory2d.Length);
+ Assert.AreEqual(2, memory2d.Width);
+ Assert.AreEqual(2, memory2d.Height);
+ Assert.AreEqual(2, memory2d.Span[0, 0]);
+ Assert.AreEqual(6, memory2d.Span[1, 1]);
// Also ensure the right exceptions are thrown with invalid parameters, such as
// negative indices, indices out of range, values that are too big, etc.
@@ -90,11 +90,11 @@ public void Test_Memory2DT_Array2DConstructor_1()
Memory2D memory2d = new(array);
Assert.IsFalse(memory2d.IsEmpty);
- Assert.AreEqual(memory2d.Length, 6);
- Assert.AreEqual(memory2d.Width, 3);
- Assert.AreEqual(memory2d.Height, 2);
- Assert.AreEqual(memory2d.Span[0, 1], 2);
- Assert.AreEqual(memory2d.Span[1, 2], 6);
+ Assert.AreEqual(6, memory2d.Length);
+ Assert.AreEqual(3, memory2d.Width);
+ Assert.AreEqual(2, memory2d.Height);
+ Assert.AreEqual(2, memory2d.Span[0, 1]);
+ Assert.AreEqual(6, memory2d.Span[1, 2]);
// Here we test the check for covariance: we can't create a Memory2D from a U[,] array
// where U is assignable to T (as in, U : T). This would cause a type safety violation on write.
@@ -114,11 +114,11 @@ public void Test_Memory2DT_Array2DConstructor_2()
Memory2D memory2d = new(array, 0, 1, 2, 2);
Assert.IsFalse(memory2d.IsEmpty);
- Assert.AreEqual(memory2d.Length, 4);
- Assert.AreEqual(memory2d.Width, 2);
- Assert.AreEqual(memory2d.Height, 2);
- Assert.AreEqual(memory2d.Span[0, 0], 2);
- Assert.AreEqual(memory2d.Span[1, 1], 6);
+ Assert.AreEqual(4, memory2d.Length);
+ Assert.AreEqual(2, memory2d.Width);
+ Assert.AreEqual(2, memory2d.Height);
+ Assert.AreEqual(2, memory2d.Span[0, 0]);
+ Assert.AreEqual(6, memory2d.Span[1, 1]);
_ = Assert.ThrowsExactly(() => new Memory2D