Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/TestFramework/TestFramework/Assertions/CollectionAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public static void AreEquivalent<T>(
}

// If both collections are empty, they are equivalent.
if (!expected.Any())
if (expectedCollectionCount == 0)
{
return;
}
Expand Down Expand Up @@ -661,13 +661,15 @@ public static void AreNotEquivalent<T>(
DebugEx.Assert(notExpected is not null, "expected is not null here");

// Check whether the element counts are different.
if (notExpected.Count() != actual.Count())
int notExpectedCount = notExpected.Count();
int actualCount = actual.Count();
if (notExpectedCount != actualCount)
{
return;
}

// If both collections are empty, they are equivalent.
if (!notExpected.Any())
if (notExpectedCount == 0)
{
string userMessage = Assert.BuildUserMessage(message);
string finalMessage = string.Format(
Expand Down Expand Up @@ -743,9 +745,8 @@ public static void AllItemsAreInstancesOfType(
int i = 0;
foreach (object? element in collection)
{
if (expectedType.GetTypeInfo() is { } expectedTypeInfo
&& element?.GetType().GetTypeInfo() is { } elementTypeInfo
&& !expectedTypeInfo.IsAssignableFrom(elementTypeInfo))
if (element?.GetType() is { } elementType
&& !expectedType.IsAssignableFrom(elementType))
{
string userMessage = Assert.BuildUserMessage(message);
string finalMessage = string.Format(
Expand Down
Loading