-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathCollectionAssert.cs
More file actions
21 lines (20 loc) · 951 Bytes
/
Copy pathCollectionAssert.cs
File metadata and controls
21 lines (20 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace HealthMonitoring.TestUtils
{
public static class CollectionAssert
{
public static void AreEquivalent<T>(IEnumerable<T> expected, IEnumerable<T> actual)
{
var expectedArray = expected.ToArray();
var actualArray = actual.ToArray();
Assert.True(expectedArray.Length == actualArray.Length,
$"Collections size are not equal - expected: {expectedArray.Length}, got: {actualArray.Length}\nExpected collection: {expectedArray}\nActual collection: {actualArray}");
var actualList = actualArray.ToList();
foreach (var expectedItem in expectedArray)
Assert.True(actualList.Remove(expectedItem),
$"Actual collection does not have element: {expectedItem}\nExpected collection: {expectedArray}\nActual collection: {actualArray}");
}
}
}