Пример #1
0
        public void NestedGraphTest()
        {
            /*      a
             *     / \
             *    b   c
             *   /   / \
             *  d   e   f
             *
             * d,e,f - b,c - a
             *
             */

            var ar = new Recipe("a");
            ar.RegisterDependency("b");
            ar.RegisterDependency("c");

            var br = new Recipe("b");
            br.RegisterDependency("d");

            var cr = new Recipe("c");
            cr.RegisterDependency("e");
            cr.RegisterDependency("f");

            var dr = new Recipe("d");
            var er = new Recipe("e");
            var fr = new Recipe("f");

            var r = new List<Recipe> {ar, br, cr, dr, er, fr};

            var sorter = new RecipeSorter();

            var output = sorter.Order(r);
            output.ShouldHaveTheSameElementsAs(dr,er,fr,br,cr,ar);
        }
Пример #2
0
        private IEnumerable<Recipe> readRecipes()
        {
            var recipes = buildEntireRecipeGraph(_graph.Recipes);

            // TODO -- log which recipes were selected
            recipes = new RecipeSorter().Order(recipes);
            return recipes;
        }