예제 #1
0
파일: Day6Test.cs 프로젝트: fluce/aoc19
        public void TestCalcTransferCount(string input, string from, string to, int expectedResult)
        {
            var parser = new InputParser(input.Split(","));

            parser.Parse();
            InputParser.Dump(parser.Roots.First(), console.WriteLine);

            console.WriteLine(string.Join(",", InputParser.GetPathToRootSpatialObject(parser.AllObjects[from]).Select(x => x.Name)));
            console.WriteLine(string.Join(",", InputParser.GetPathToRootSpatialObject(parser.AllObjects[to]).Select(x => x.Name)));

            var(degenerative, n) = parser.CalculateOrbitalTransfersCount(parser.AllObjects[from], parser.AllObjects[to], console.WriteLine);
            if (degenerative)
            {
                console.WriteLine("Degenerative case");
            }
            Assert.Equal(expectedResult, n);
        }