Example #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);
        }
Example #2
0
        public void append_recipe_pushes_hosts_from_one_to_another()
        {
            var recipe1 = new Recipe("1");
            var recipe2 = new Recipe("2");

            recipe1.HostFor("h1").RegisterValue<OneSettings>(x => x.Age, 1);
            recipe2.HostFor("h2").RegisterValue<TwoSettings>(x => x.City, "Jasper");

            recipe1.AppendBehind(recipe2);

            recipe1.Hosts.Select(x => x.Name).ShouldHaveTheSameElementsAs("h1", "h2");
        }
Example #3
0
        public void append_recipe_host_data_precedence_favors_the_dependee()
        {
            var recipe1 = new Recipe("1");
            var recipe2 = new Recipe("2");

            recipe1.HostFor("h1").RegisterValue<OneSettings>(x => x.Age, 1);
            recipe2.HostFor("h1").RegisterValue<OneSettings>(x => x.Name, "Tommy");
            recipe2.HostFor("h1").RegisterValue<OneSettings>(x => x.Age, 15);

            recipe1.AppendBehind(recipe2);

            var host = recipe1.HostFor("h1");

            var settings = host.GetDirective<OneSettings>();
            settings.Age.ShouldEqual(1);
        }
Example #4
0
        public void append_recipe_appends_hosts()
        {
            var recipe1 = new Recipe("1");
            var recipe2 = new Recipe("2");

            recipe1.HostFor("h1").RegisterValue<OneSettings>(x => x.Age, 1);
            recipe2.HostFor("h1").RegisterValue<OneSettings>(x => x.Name, "Tommy");

            recipe1.AppendBehind(recipe2);

            var host = recipe1.HostFor("h1");

            var settings = host.GetDirective<OneSettings>();

            settings.Age.ShouldEqual(1);
            settings.Name.ShouldEqual("Tommy");
        }
Example #5
0
        public void SetUp()
        {
            var writer = new DeploymentWriter("profile3");

            var recipeDefinition = writer.RecipeFor("r1");
            recipeDefinition.RegisterDependency("the-pig");
            recipeDefinition.RegisterDependency("freestate");

            var host = recipeDefinition.HostFor("h1");

            host.AddDirective(new SimpleSettings
            {
                One = "one",
                Two = "two"
            });

            host.AddDirective(new OneSettings()
            {
                Name = "Jeremy",
                Age = 37
            });

            host.AddReference(new BottleReference()
            {
                Name = "bottle1"
            });

            host.AddReference(new BottleReference()
            {
                Name = "bottle2"
            });

            recipeDefinition.HostFor("h2").AddProperty<ThreeSettings>(x => x.Direction, "North");
            recipeDefinition.HostFor("h3").AddProperty<TwoSettings>(x => x.City, "Austin");

            writer.Flush(FlushOptions.Wipeout);

            theRecipe = RecipeReader.ReadFrom("profile3/recipes/r1");
        }
Example #6
0
 public bool Equals(Recipe other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other._name, _name);
 }
Example #7
0
 public void AppendBehind(Recipe recipe)
 {
     recipe.Hosts.Each(other => _hosts[other.Name].Append(other));
 }