-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTopologicalSortTests.cs
43 lines (38 loc) · 1.27 KB
/
TopologicalSortTests.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
36
37
38
39
40
41
42
43
using System.Collections.Generic;
using Xunit;
using Xunit.Extensions.TestDependency;
namespace Xunit.Extensions.TestDependency_Tests
{
public class Sort
{
[Fact]
[Trait("xUnit", "TopologicalSort")]
// ReSharper disable once InconsistentNaming
public void TopologicalSortTest()
{
var t = typeof(Xunit.Extensions.TestDependency.DependencyOrderer);
var a = new Item("A");
var b = new Item("B", "C", "E");
var c = new Item("C");
var d = new Item("D", "A");
var e = new Item("E", "D", "G");
var f = new Item("F");
var g = new Item("G", "F", "H");
var h = new Item("H");
var unsorted = new[] { a, b, c, d, e, f, g, h };
var expected = new[] { a, c, d, f, h, g, e, b };
var sorted = unsorted.TSort(x => x.Dependencies, y => y.DisplayName);
Assert.Equal(expected, sorted);
}
}
public class Item
{
public IEnumerable<string> Dependencies { get; private set; }
public string DisplayName { get; }
public Item(string name, params string[] dependencies)
{
DisplayName = name;
Dependencies = dependencies;
}
}
}