Пример #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\" />");
        }
        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");
        }
        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");
        }
Пример #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;
        }
        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");
        }
        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");
        }
        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"));
        }
Пример #8
0
 public void CopyTo(Substitutions substitutions2)
 {
     _values.Each(substitutions2.Set);
 }
Пример #9
0
 public string Contents(Substitutions substitutions)
 {
     return substitutions.ApplySubstitutions(RawText);
 }
Пример #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");
        }
Пример #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);
        }
Пример #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");
        }
Пример #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();
        }
Пример #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");
        }
Пример #15
0
        public void set_overrides()
        {
            var substitutions = new Substitutions();
            substitutions.Set("key", "something");
            substitutions.Set("key", "different");

            substitutions.ValueFor("key").ShouldEqual("different");
        }
Пример #16
0
 public void CopyTo(Substitutions substitutions2)
 {
     _values.Each(substitutions2.Set);
 }