コード例 #1
0
ファイル: Day6Test.cs プロジェクト: fluce/aoc19
        public void TestGetPathToRoot(string input, string from, string expectedResult)
        {
            var parser = new InputParser(input.Split(","));

            parser.Parse();
            InputParser.Dump(parser.Roots.First(), console.WriteLine);
            var r = string.Join(",", InputParser.GetPathToRootSpatialObject(parser.AllObjects[from]).Select(x => x.Name));

            Assert.Equal(expectedResult, r);
        }
コード例 #2
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);
        }