public async Task CompilationRenderer_SpecialTests_Async(SpecTest data)
        {
            var builder = new CompilerSettingsBuilder();

            var stubble = new StubbleCompilationRenderer(builder.BuildSettings());

            if (data.ExpectedException != null)
            {
                var ex = await Assert.ThrowsAsync(data.ExpectedException.GetType(), CompileAndRender);

                Assert.Equal(data.ExpectedException.Message, ex.Message);
            }
            else
            {
                Assert.Equal(data.Expected, await CompileAndRender());
            }

            async Task <string> CompileAndRender()
            {
                var output = data.Partials != null ?
                             await stubble.CompileAsync(data.Template, data.Data, data.Partials) :
                             await stubble.CompileAsync(data.Template, data.Data);

                return((string)output(data.Data));
            }
        }
        public void CompilationRenderer_SpecialTests(SpecTest data)
        {
            var builder = new CompilerSettingsBuilder();

            var stubble = new StubbleCompilationRenderer(builder.BuildSettings());

            if (data.ExpectedException != null)
            {
                var ex = Assert.Throws(data.ExpectedException.GetType(), () =>
                {
                    CompileAndRender();
                });

                Assert.Equal(data.ExpectedException.Message, ex.Message);
            }
            else
            {
                Assert.Equal(data.Expected, CompileAndRender());
            }

            string CompileAndRender()
            {
                var output = data.Partials != null?
                             stubble.Compile(data.Template, data.Data, data.Partials) :
                                 stubble.Compile(data.Template, data.Data);

                return((string)output(data.Data));
            }
        }
Пример #3
0
        public async Task StringRendererSpecTest_Async(SpecTest data)
        {
            OutputStream.WriteLine(data.Name);
            var stubble = new StubbleVisitorRenderer();
            var output  = await(data.Partials != null ? stubble.RenderAsync(data.Template, data.Data, data.Partials) : stubble.RenderAsync(data.Template, data.Data));

            OutputStream.WriteLine("Expected \"{0}\", Actual \"{1}\"", data.Expected, output);
            Assert.Equal(data.Expected, output);
        }
Пример #4
0
        public async Task CompilationRendererSpecTest_Async(SpecTest data)
        {
            OutputStream.WriteLine(data.Name);

            var stubble = new StubbleCompilationRenderer(Settings);
            var output  = await(data.Partials != null ? stubble.CompileAsync(data.Template, data.Data, data.Partials) : stubble.CompileAsync(data.Template, data.Data));

            var outputResult = output(data.Data);

            OutputStream.WriteLine("Expected \"{0}\", Actual \"{1}\"", data.Expected, outputResult);
            Assert.Equal(data.Expected, outputResult);
        }
Пример #5
0
        public async Task StringRendererSpecTest_Async(SpecTest data)
        {
            var settings = RenderSettings.GetDefaultRenderSettings();

            settings.CultureInfo = data.CultureInfo ?? settings.CultureInfo;

            OutputStream.WriteLine(data.Name);
            var stubble = new StubbleVisitorRenderer();
            var output  = await(data.Partials != null ? stubble.RenderAsync(data.Template, data.Data, data.Partials, settings) : stubble.RenderAsync(data.Template, data.Data, settings));

            OutputStream.WriteLine("Expected \"{0}\", Actual \"{1}\"", data.Expected, output);
            Assert.Equal(data.Expected, output);
        }
Пример #6
0
        public void CompilationRendererSpecTest(SpecTest data)
        {
            OutputStream.WriteLine(data.Name);
            var settings = CompilationSettings.GetDefaultRenderSettings();

            settings.CultureInfo = data.CultureInfo ?? settings.CultureInfo;

            var stubble = new StubbleCompilationRenderer();
            var output  = data.Partials != null?stubble.Compile(data.Template, data.Data, data.Partials, settings) : stubble.Compile(data.Template, data.Data, settings);

            var outputResult = output(data.Data);

            OutputStream.WriteLine("Expected \"{0}\", Actual \"{1}\"", data.Expected, outputResult);
            Assert.Equal(data.Expected, outputResult);
        }