Inheritance: ScriptElement
示例#1
0
        public void CanImplicitlyConvertToString()
        {
            var scriptBlock = new ScriptBlock("function myFunction() { }");

            String script = scriptBlock;

            Assert.Equal(scriptBlock.ToScriptFragment(), script);
        }
示例#2
0
        public void WrapScriptBlockWithScriptTag()
        {
            var scriptBlock = new ScriptBlock("function myFunction() { }");

            Assert.Equal(
              String.Format(ScriptResources.ScriptBlockFormat, "function myFunction() { }"),
              scriptBlock.ToScriptFragment()
            );
        }
示例#3
0
        public void AlwaysAppendBlockToExistingScript()
        {
            var block1 = new ScriptBlock("var x = 0;");
            var block2 = new ScriptBlock("var y = 1;");
            var block3 = new ScriptBlock("var z = 2;");
            var script = new TestScript();

            script.AppendBlock(block1);
            script.AppendBlock(block2);
            script.AppendBlock(block3);

            Assert.Equal(block1 + Environment.NewLine + block2 + Environment.NewLine + block3 + Environment.NewLine, script.ToString());
        }
示例#4
0
        public void AppendBlock(ScriptBlock scriptBlock)
        {
            Verify.NotNull(scriptBlock, "scriptBlock");

            _script.AppendLine(scriptBlock.ToScriptFragment());
        }