public void Rendering_replaces_template_key_with_model_value()
        {
            var template = new Template(_name, "${SomeKey} SomeKey", _factory);
            _templateModel.Stub(m => m.GetProperty("SomeKey")).Return("some value");

            template.PrepareDynamicRendering();
            var renderedText = template.Render(_viewModel);

            Assert.AreEqual("some value SomeKey", renderedText);
        }
        public void Rendering_replaces_several_occurances_of_the_same_template_key_with_the_same_model_value()
        {
            var template = new Template(_name, "${Repeat}, ${Repeat}, ${Repeat}, ${Repeat} Claudius!", _factory);
            _templateModel.Stub(m => m.GetProperty("Repeat")).Return("I");

            template.PrepareDynamicRendering();
            var renderedText = template.Render(_viewModel);

            Assert.AreEqual("I, I, I, I Claudius!", renderedText);
        }
        public void Rendering_capitalises_template_key()
        {
            var template = new Template(_name, "${minusculeName}", _factory);
            _templateModel.Stub(m => m.GetProperty("MinusculeName")).Return("I got capitalised!");

            template.PrepareDynamicRendering();
            var renderedText = template.Render(_viewModel);

            Assert.AreEqual("I got capitalised!", renderedText);
        }
        public void Rendering_replaces_several_template_keys_with_model_values()
        {
            var template = new Template(_name, "count: ${FirstKey}, ${SecondKey}, ${ThirdKey}", _factory);
            _templateModel.Stub(m => m.GetProperty("FirstKey")).Return("One");
            _templateModel.Stub(m => m.GetProperty("SecondKey")).Return("Two");
            _templateModel.Stub(m => m.GetProperty("ThirdKey")).Return("Three");

            template.PrepareDynamicRendering();
            var renderedText = template.Render(_viewModel);

            Assert.AreEqual("count: One, Two, Three", renderedText);
        }
        public void Rendering_untemplated_text_replaces_nothing()
        {
            var text = "${TemplateKey";
            var text2 = "{TemplateKey}";
            var text3 = "$TemplateKey}";
            var text4 = "TemplateKey";

            var template = new Template(_name, text, _factory);
            var template2 = new Template(_name, text2, _factory);
            var template3 = new Template(_name, text3, _factory);
            var template4 = new Template(_name, text4, _factory);
            _templateModel.Stub(m => m.GetProperty("TemplateKey")).Return("Different value")
                .Repeat.Times(4);

            template.PrepareDynamicRendering();
            template2.PrepareDynamicRendering();
            template3.PrepareDynamicRendering();
            template4.PrepareDynamicRendering();

            var renderedText = template.Render(_viewModel);
            var renderedText2 = template2.Render(_viewModel);
            var renderedText3 = template3.Render(_viewModel);
            var renderedText4 = template4.Render(_viewModel);

            Assert.AreEqual(text, renderedText);
            Assert.AreEqual(text2, renderedText2);
            Assert.AreEqual(text3, renderedText3);
            Assert.AreEqual(text4, renderedText4);
        }