public void CountLevelsReturnsNumberOfLevelsInGraph2() { var graph = GraphTestHelper.CreateEmptyGraph(TargetGraph); graph.AddSequences(new[] { new[] { 1, 2, 6 }, new[] { 2, 3, 4, 5 }, new[] { 9, 8, 7, 6 }, }); Assert.AreEqual(6, graph.CountLevels); }
public void ConstructorWithInitialSequenceArgumentInitializesGraph() { var target = GraphTestHelper.CreateEmptyGraph(TargetGraph); target.AddSequence(new[] { 1, 2, 3, 4, 5 }); Assert.AreEqual(5, target.CountNodes); GraphTestHelper.AssertConsistsOfSequences(target, new[] { new[] { 1, 2 }, new[] { 2, 3 }, new[] { 3, 4 }, new[] { 4, 5 }, new[] { 1, 2, 3, 4, 5 }, }); }
public void AddAddsSequence() { var target = GraphTestHelper.CreateEmptyGraph(TargetGraph); target.AddSequence(new [] { 0, 1 }); target.AddSequence(new [] { 1, 2 }); target.AddSequence(new [] { 2, 3 }); target.AddSequence(new [] { 3, 4 }); target.AddSequence(new [] { 4, 5 }); target.AddSequence(new [] { 5, 6 }); target.AddSequence(new [] { 6, 7 }); target.AddSequence(new [] { 7, 8 }); target.AddSequence(new [] { 8, 9 }); Assert.AreEqual(10, target.CountNodes); GraphTestHelper.AssertConsistsOfSequences(target, new[] { new[] { 0, 1 }, new[] { 1, 2 }, new[] { 2, 3 }, new[] { 3, 4 }, new[] { 4, 5 }, new[] { 5, 6 }, new[] { 6, 7 }, new[] { 7, 8 }, new[] { 8, 9 }, new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, }); GraphTestHelper.AssertConsistsOfBackSequences(target, new[] { new[] { 1, 0 }, new[] { 2, 1 }, new[] { 3, 2 }, new[] { 4, 3 }, new[] { 5, 4 }, new[] { 6, 5 }, new[] { 7, 6 }, new[] { 8, 7 }, new[] { 9, 8 }, new[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, }); }
public void InitialLevelCalculatesCorrectly() { var graph = GraphTestHelper.CreateEmptyGraph(TargetGraph); graph.AddSequences(new[] { new[] { 2, 4, 3, 9 }, new[] { 1, 3 }, new[] { 4, 5, 7, 8, 3 }, new[] { 4, 6, 8 }, new[] { 2, 9 }, }); var countLevels = graph.CountLevels; for (var level = 0; level < countLevels; level++) { var nodesOnLevel = graph.GetNodes(level).Count(); Assert.IsTrue(nodesOnLevel > 0); } }
public void AddRangeAddsSequences() { var graph = GraphTestHelper.CreateEmptyGraph(TargetGraph); graph.AddSequences(new [] { new[] { 41, 51, 61, 100 }, new[] { 42, 52, 62, 100 }, }); Assert.AreEqual(7, graph.CountNodes); GraphTestHelper.AssertConsistsOfSequences(graph, new[] { new[] { 41, 51 }, new[] { 51, 61 }, new[] { 61, 100 }, new[] { 42, 52 }, new[] { 52, 62 }, new[] { 62, 100 }, new[] { 41, 51, 61, 100 }, new[] { 42, 52, 62, 100 }, }); }
public void SingleSequenceCannotBeAdded() { var graph = GraphTestHelper.CreateEmptyGraph(TargetGraph); graph.AddSequence(new[] { 1 }); }