public void TestCalculateOrbits() { string input = @"COM)B,B)C,C)D,D)E,E)F,B)G,G)H,D)I,E)J,J)K,K)L"; var parser = new InputParser(input.Split(",")); parser.Parse(); Assert.Single(parser.Roots); InputParser.Dump(parser.Roots.First(), console.WriteLine); Assert.Equal(3, InputParser.CalculateDirectAndIndirectOrbits(parser.AllObjects["D"])); Assert.Equal(7, InputParser.CalculateDirectAndIndirectOrbits(parser.AllObjects["L"])); Assert.Equal(0, InputParser.CalculateDirectAndIndirectOrbits(parser.AllObjects["COM"])); var result = parser.AllObjects.Values.Sum(InputParser.CalculateDirectAndIndirectOrbits); Assert.Equal(42, result); }