-
Notifications
You must be signed in to change notification settings - Fork 0
/
AbstractRivalsTest.cs
35 lines (33 loc) · 1.32 KB
/
AbstractRivalsTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace Rivals
{
public class AbstractRivalsTest
{
protected static void AssertResult(IEnumerable<OwnedLocation> expectedResult, IEnumerable<OwnedLocation> actualResult)
{
var actual = actualResult.ToLookup(l => l.Location);
var expected = expectedResult.ToDictionary(l => l.Location);
foreach (var expectedLocation in expected)
{
var actualLocation = actual[expectedLocation.Key].ToArray();
if (actualLocation.Length > 1)
{
var allActual = string.Join<OwnedLocation>(", ", actualLocation);
Assert.Fail($"Multiple OwnedLocation's with same location {expectedLocation.Key}: {allActual}");
}
if (actualLocation.Length == 0)
{
Assert.Fail($"Not found OwnedLocation with location: {expectedLocation.Key}");
}
Assert.AreEqual(expectedLocation.Value, actualLocation[0]);
}
foreach (var location in actual)
{
if (!expected.ContainsKey(location.Key))
Assert.Fail($"Found extra OwnedLocation: {location.First()}");
}
}
}
}