Ejemplo n.º 1
0
        public void get_content()
        {
            var substitutions = new Substitutions();
            substitutions.Set("%MODEL%", "Foo.Bar");

            var template = FileTemplate.Embedded("view.spark");
            template.Contents(substitutions).ShouldContain("<viewdata model=\"Foo.Bar\" />");
        }
Ejemplo n.º 2
0
        public void set_if_none_will_not_override_if_it_exists()
        {
            var substitutions = new Substitutions();
            substitutions.Set("key", "something");
            substitutions.SetIfNone("key", "different");

            substitutions.ValueFor("key").ShouldEqual("something");
        }
Ejemplo n.º 3
0
        public void apply_substitutions()
        {
            var substitutions = new Substitutions();
            substitutions.Set("%KEY%", "the key");
            substitutions.Set("%NAME%", "George Michael");

            string text = "%KEY% is %NAME%";
            substitutions.ApplySubstitutions(text)
                         .ShouldEqual("the key is George Michael");
        }
Ejemplo n.º 4
0
        public static string Write(FileTemplate template, Location location, string inputModel)
        {
            var substitutions = new Substitutions();
            substitutions.Set("%MODEL%", inputModel);

            var path = location.CurrentFolder.AppendPath(inputModel.Split('.').Last() + template.Extension);
            var contents = template.Contents(substitutions);

            new FileSystem().WriteStringToFile(path, contents);

            return path;
        }
Ejemplo n.º 5
0
        public void copy_to()
        {
            var substitutions = new Substitutions();
            substitutions.Set("key", "something");
            substitutions.Set("two", "twenty");

            var substitutions2 = new Substitutions();
            substitutions.CopyTo(substitutions2);

            substitutions2.ValueFor("key").ShouldEqual("something");
            substitutions2.ValueFor("two").ShouldEqual("twenty");
        }
Ejemplo n.º 6
0
        public void read_has_set_if_none_semantics()
        {
            var substitutions = new Substitutions();
            substitutions.Set("key", "something");
            substitutions.Set("two", "twenty");

            substitutions.WriteTo("fubu.template.config");

            var substitutions2 = new Substitutions();
            substitutions2.Set("key", "ORIGINAL");
            substitutions2.ReadFrom("fubu.template.config");

            substitutions2.ValueFor("key").ShouldEqual("ORIGINAL");
            substitutions2.ValueFor("two").ShouldEqual("twenty");
        }
Ejemplo n.º 7
0
        public void reading_inputs_that_have_no_known_values_throws()
        {
            var substitutions = new Substitutions();
            substitutions.Set("key", "something");

            var markMissing = MockRepository.GenerateMock<Action<string>>();

            var inputs = new[]
            {
                new Input {Name = "Foo"},
                new Input {Name = "Bar"},
            };

            substitutions.ReadInputs(inputs, markMissing);

            markMissing.AssertWasCalled(x => x.Invoke("Foo"));
            markMissing.AssertWasCalled(x => x.Invoke("Bar"));
        }
Ejemplo n.º 8
0
 public void CopyTo(Substitutions substitutions2)
 {
     _values.Each(substitutions2.Set);
 }
Ejemplo n.º 9
0
 public string Contents(Substitutions substitutions)
 {
     return substitutions.ApplySubstitutions(RawText);
 }
Ejemplo n.º 10
0
        public void set_if_none_will_write_if_no_previous_value()
        {
            var substitutions = new Substitutions();
            substitutions.SetIfNone("key", "different");

            substitutions.ValueFor("key").ShouldEqual("different");
        }
Ejemplo n.º 11
0
        public void SetUp()
        {
            markMissing = MockRepository.GenerateMock<Action<string>>();

            substitutions = new Substitutions();
            substitutions.Set("%SHORT_NAME%", "BigProject");

            var inputs = new[]
            {
                new Input("%REGISTRY%=%SHORT_NAME%Registry"),
                new Input("Foo=Bar"),
                new Input("%SHORT_NAME%=different")
            };

            substitutions.ReadInputs(inputs, markMissing);
        }
Ejemplo n.º 12
0
        public void write_and_read()
        {
            var substitutions = new Substitutions();
            substitutions.Set("key", "something");
            substitutions.Set("two", "twenty");

            substitutions.WriteTo("fubu.template.config");

            var substitutions2 = new Substitutions();
            substitutions2.ReadFrom("fubu.template.config");

            substitutions2.ValueFor("key").ShouldEqual("something");
            substitutions2.ValueFor("two").ShouldEqual("twenty");
        }
Ejemplo n.º 13
0
        public void substitutions_do_not_write_instructions()
        {
            var substitutions = new Substitutions();
            substitutions.Set("key", "something");
            substitutions.Set("two", "twenty");
            substitutions.Set(TemplatePlan.INSTRUCTIONS, "something");

            substitutions.WriteTo("fubu.template.config");

            var substitutions2 = new Substitutions();
            substitutions2.ReadFrom("fubu.template.config");

            substitutions2.Has(TemplatePlan.INSTRUCTIONS).ShouldBeFalse();
        }
Ejemplo n.º 14
0
        public void set_value()
        {
            var substitutions = new Substitutions();
            substitutions.Set("key", "something");
            substitutions.Set("two", "twenty");

            substitutions.ValueFor("key").ShouldEqual("something");
            substitutions.ValueFor("two").ShouldEqual("twenty");
        }
Ejemplo n.º 15
0
        public void set_overrides()
        {
            var substitutions = new Substitutions();
            substitutions.Set("key", "something");
            substitutions.Set("key", "different");

            substitutions.ValueFor("key").ShouldEqual("different");
        }
Ejemplo n.º 16
0
 public void CopyTo(Substitutions substitutions2)
 {
     _values.Each(substitutions2.Set);
 }