예제 #1
0
        private static void _ComplexCases(string[] dependency)
        {
            var target = new TopologicalSort();

            string actual = target.Solve(dependency);

            foreach (var item in dependency)
            {
                string[] split = item.Split(',');

                Assert.IsTrue(actual.IndexOf(split[0]) < actual.IndexOf(split[1]));
            }
        }
예제 #2
0
        public void BasicDependencyCase()
        {
            var dependency = new string[]
            {
                "a,b",
                "b,c",
                "c,d"
            };

            string expected = "a,b,c,d";

            var target = new TopologicalSort();

            string actual = target.Solve(dependency);

            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        public void MultiplePossibleDependencyCase()
        {
            var dependency = new string[]
            {
                "a,b",
                "c,b",
            };

            string[] expected =
            {
                "a,c,b",
                "c,a,b",
            };

            var target = new TopologicalSort();

            string actual = target.Solve(dependency);

            Assert.IsTrue(expected.Contains(actual));
        }