public void Should_identify_two_chains() { Dictionary <int, Chain> chains = new Dictionary <int, Chain>(); AddChain(chains, 5, new List <int> { 5, 8 }); AddChain(chains, 7, new List <int> { 6, 7 }); AddChain(chains, 8, new List <int> { 9, 8, 5 }); AddChain(chains, 9, new List <int> { 9, 8 }); AddChain(chains, 6, new List <int> { 6, 7 }); ChainingCalculator calculator = new ChainingCalculator(); var identifiedChains = calculator.IdentifyChains(chains); Check.That(identifiedChains[0].Contains(8)).IsTrue(); Check.That(identifiedChains[0].Contains(9)).IsTrue(); Check.That(identifiedChains[0].Contains(5)).IsTrue(); Check.That(identifiedChains[1].Contains(6)).IsTrue(); Check.That(identifiedChains[1].Contains(7)).IsTrue(); Check.That(identifiedChains.Count).IsEqualTo(2); }
public void Should_identify_chain_with_one_chain_element() { Dictionary <int, Chain> chains = new Dictionary <int, Chain>(); AddChain(chains, 5, new List <int> { 5 }); ChainingCalculator calculator = new ChainingCalculator(); var identifiedChains = calculator.IdentifyChains(chains); Check.That(identifiedChains[0].Contains(5)).IsTrue(); }
public void Should_return_four_identified_chains() { var items = new List <Item> { new Item(11, null, null), new Item(10, null, null), new Item(9, null, 8), new Item(8, 9, null), new Item(7, null, null), new Item(6, null, 7), new Item(5, 8, null) }; ChainingCalculator calculator = new ChainingCalculator(); var chains = calculator.CreateChains(items); var identifiedChains = calculator.IdentifyChains(chains); Check.That(identifiedChains.Count).IsEqualTo(4); }