当前位置: 首页>>代码示例>>C#>>正文


C# Fakes.FakeViewEngineHost类代码示例

本文整理汇总了C#中Nancy.Tests.Fakes.FakeViewEngineHost的典型用法代码示例。如果您正苦于以下问题:C# FakeViewEngineHost类的具体用法?C# FakeViewEngineHost怎么用?C# FakeViewEngineHost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FakeViewEngineHost类属于Nancy.Tests.Fakes命名空间,在下文中一共展示了FakeViewEngineHost类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_expand_partial_inside_each_section_with_current_as_model

        public void Should_expand_partial_inside_each_section_with_current_as_model()
        {
            const string input = @"<html><head></head><body>@Each;@Partial['testing', @Current];@EndEach</body></html>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.GetTemplateCallback = (s, m) => "Hi @Model ";
            var model = new List<string>() { "foo", "bar" };

            var result = viewEngine.Render(input, model, fakeViewEngineHost);

            Assert.Equal(@"<html><head></head><body>Hi foo Hi bar </body></html>", result);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:11,代码来源:SuperSimpleViewEngineTests.cs

示例2: Should_expand_multiple_partials_inside_each_section

        public void Should_expand_multiple_partials_inside_each_section()
        {
            const string input = @"<html><head></head><body>@Each;@Partial['greeting'], @Partial['name'];@EndEach</body></html>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.GetTemplateCallback = (s, m) =>
            {
                return (s.Equals("greeting")) ? "Hi" : "Nancy";
            };
            var model = new List<string>() { "foo", "bar" };

            var result = viewEngine.Render(input, model, fakeViewEngineHost);

            Assert.Equal(@"<html><head></head><body>Hi, NancyHi, Nancy</body></html>", result);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:14,代码来源:SuperSimpleViewEngineTests.cs

示例3: Should_expand_partial_inside_each_section_with_parameter_of_current_as_model

        public void Should_expand_partial_inside_each_section_with_parameter_of_current_as_model()
        {
            const string input = @"<html><head></head><body>@Each;@Partial['testing', @Current.Name];@EndEach</body></html>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.GetTemplateCallback = (s, m) => "Hi @Model ";

            dynamic foo = new ExpandoObject();
            foo.Name = "foo";

            dynamic bar = new ExpandoObject();
            bar.Name = "bar";

            var model = new List<ExpandoObject>() { foo, bar };

            var result = viewEngine.Render(input, model, fakeViewEngineHost);

            Assert.Equal(@"<html><head></head><body>Hi foo Hi bar </body></html>", result);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:18,代码来源:SuperSimpleViewEngineTests.cs

示例4: Should_handle_master_page_hierarchies

        public void Should_handle_master_page_hierarchies()
        {
            const string input = "@Master['middle']\r\[email protected]['MiddleContent'][email protected]";
            const string middle = "@Master['top']\r\[email protected]['TopContent']Top\r\[email protected]['MiddleContent']@EndSection";
            const string top = "Top! @Section['TopContent']";

            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.GetTemplateCallback = (s, m) => s == "middle" ? middle : top;
            var viewEngine = new SuperSimpleViewEngine();

            var result = viewEngine.Render(input, null, fakeViewEngineHost);

            Assert.Equal("Top! Top\r\nMiddle", result);
        }
开发者ID:ninjaferret,项目名称:Nancy,代码行数:14,代码来源:SuperSimpleViewEngineTests.cs

示例5: Should_expand_partial_content_with_specified_model_property_if_specified

        public void Should_expand_partial_content_with_specified_model_property_if_specified()
        {
            const string input = @"<html><head></head><body>@Partial['testing', Model.User];</body></html>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.GetTemplateCallback = (s, m) => "Hello @Model.Name";
            dynamic model = new ExpandoObject();
            dynamic subModel = new ExpandoObject();
            model.Name = "Jim";
            subModel.Name = "Bob";
            model.User = subModel;
            var viewEngine = new SuperSimpleViewEngine();

            var result = viewEngine.Render(input, model, fakeViewEngineHost);

            Assert.Equal(@"<html><head></head><body>Hello Bob</body></html>", result);
        }
开发者ID:ninjaferret,项目名称:Nancy,代码行数:16,代码来源:SuperSimpleViewEngineTests.cs

示例6: Should_expand_partial_content_even_with_no_model

        public void Should_expand_partial_content_even_with_no_model()
        {
            const string input = @"<html><head></head><body>@Partial['testing'];</body></html>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.GetTemplateCallback = (s, m) => "Test partial content";
            var viewEngine = new SuperSimpleViewEngine();

            var result = viewEngine.Render(input, null, fakeViewEngineHost);

            Assert.Equal(@"<html><head></head><body>Test partial content</body></html>", result);
        }
开发者ID:ninjaferret,项目名称:Nancy,代码行数:11,代码来源:SuperSimpleViewEngineTests.cs

示例7: Should_expand_anti_forgery_tokens

        public void Should_expand_anti_forgery_tokens()
        {
            const string input = "<html><body><form>@AntiForgeryToken</form><body></html>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            var viewEngine = new SuperSimpleViewEngine();

            var result = viewEngine.Render(input, null, fakeViewEngineHost);

            Assert.Equal("<html><body><form>CSRF</form><body></html>", result);
        }
开发者ID:ninjaferret,项目名称:Nancy,代码行数:10,代码来源:SuperSimpleViewEngineTests.cs

示例8: Should_call_to_expand_paths

        public void Should_call_to_expand_paths()
        {
            const string input = @"<script src='@Path['~/scripts/test.js']'></script>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.ExpandPathCallBack = s => s.Replace("~/", "/BasePath/");
            var viewEngine = new SuperSimpleViewEngine();

            var result = viewEngine.Render(input, null, fakeViewEngineHost);

            Assert.Equal("<script src='/BasePath/scripts/test.js'></script>", result);
        }
开发者ID:ninjaferret,项目名称:Nancy,代码行数:11,代码来源:SuperSimpleViewEngineTests.cs

示例9: Should_also_expand_master_page_with_same_model

        public void Should_also_expand_master_page_with_same_model()
        {
            const string input = "@Master['myMaster']\r\[email protected]['Header'];\r\nHeader\r\[email protected]\r\[email protected]['Footer']\r\nFooter\r\[email protected]";
            const string master = @"Hello @Model.Name!<div id='header'>@Section['Header'];</div><div id='footer'>@Section['Footer'];</div>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.GetTemplateCallback = (s, m) => master;
            var viewEngine = new SuperSimpleViewEngine();

            var result = viewEngine.Render(input, new { Name = "Bob" }, fakeViewEngineHost);

            Assert.Equal("Hello Bob!<div id='header'>\r\nHeader\r\n</div><div id='footer'>\r\nFooter\r\n</div>", result);
        }
开发者ID:ninjaferret,项目名称:Nancy,代码行数:12,代码来源:SuperSimpleViewEngineTests.cs

示例10: Should_expand_multiple_partial_inside_each_section_with_different_parameter_of_current_as_model

        public void Should_expand_multiple_partial_inside_each_section_with_different_parameter_of_current_as_model()
        {
            const string input = @"<html><head></head><body>@Each;@Partial['first', @Current.First];[email protected]['second', @Current.Last];@EndEach</body></html>";

            var fakeViewEngineHost = new FakeViewEngineHost
            {
                GetTemplateCallback = (s, m) =>
                {
                    return (s.Equals("first")) ?
                        "Hi @Model" :
                        "Hello @Model";
                }
            };

            dynamic foo = new ExpandoObject();
            foo.First = "foo";
            foo.Last = "bar";

            dynamic bar = new ExpandoObject();
            bar.First = "baz";
            bar.Last = "bin";

            var model = new List<ExpandoObject>() { foo, bar };

            var result = viewEngine.Render(input, model, fakeViewEngineHost);

            Assert.Equal(@"<html><head></head><body>Hi foo-Hello barHi baz-Hello bin</body></html>", result);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:28,代码来源:SuperSimpleViewEngineTests.cs

示例11: Should_expand_basic_partials

        public void Should_expand_basic_partials()
        {
            const string input = @"<html><head></head><body>@Partial['testing'];</body></html>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.GetTemplateCallback = (s, m) => "Test partial content";

            var result = viewEngine.Render(input, new object(), fakeViewEngineHost);

            Assert.Equal(@"<html><head></head><body>Test partial content</body></html>", result);
        }
开发者ID:kppullin,项目名称:Nancy,代码行数:10,代码来源:SuperSimpleViewEngineTests.cs

示例12: Should_also_expand_master_page_with_same_context

        public void Should_also_expand_master_page_with_same_context()
        {
            const string input = "@Master['myMaster']\r\[email protected]['Header'];\r\nHeader\r\[email protected]\r\[email protected]['Footer']\r\nFooter\r\[email protected]";
            const string master = @"Hello @Context.Name!<div id='header'>@Section['Header'];</div><div id='footer'>@Section['Footer'];</div>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.GetTemplateCallback = (s, m) => master;

            var result = viewEngine.Render(input, null, fakeViewEngineHost);

            Assert.Equal("Hello Frank!<div id='header'>\r\nHeader\r\n</div><div id='footer'>\r\nFooter\r\n</div>", result);
        }
开发者ID:kppullin,项目名称:Nancy,代码行数:11,代码来源:SuperSimpleViewEngineTests.cs

示例13: Should_expand_partial_inside_each_section_with_property_parameter_of_current_as_model

        public void Should_expand_partial_inside_each_section_with_property_parameter_of_current_as_model()
        {
            const string input = @"<html><head></head><body>@Each;@Partial['testing', @Current.FirstName];@EndEach</body></html>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.GetTemplateCallback = (s, m) => "Hi @Model ";

            var clark  = new PersonWithAgeField()
            {
                FirstName = "Clark",
            };

            var lois = new PersonWithAgeField()
            {
                FirstName = "Lois",
            };

            var model = new List<PersonWithAgeField>() { clark, lois };

            var result = viewEngine.Render(input, model, fakeViewEngineHost);

            Assert.Equal(@"<html><head></head><body>Hi Clark Hi Lois </body></html>", result);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:22,代码来源:SuperSimpleViewEngineTests.cs

示例14: Should_replace_sections_in_master_page

        public void Should_replace_sections_in_master_page()
        {
            const string input = "@Master['myMaster']\r\[email protected]['Header'];\r\nHeader\r\[email protected]\r\[email protected]['Footer']\r\nFooter\r\[email protected]";
            const string master = @"<div id='header'>@Section['Header'];</div><div id='footer'>@Section['Footer'];</div>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.GetTemplateCallback = (s, m) => master;
            var viewEngine = new SuperSimpleViewEngine();

            var result = viewEngine.Render(input, null, fakeViewEngineHost);

            Assert.Equal("<div id='header'>\r\nHeader\r\n</div><div id='footer'>\r\nFooter\r\n</div>", result);
        }
开发者ID:ninjaferret,项目名称:Nancy,代码行数:12,代码来源:SuperSimpleViewEngineTests.cs

示例15: Should_expand_partial_content_with_context

        public void Should_expand_partial_content_with_context()
        {
            const string input = @"<html><head></head><body>@Partial['testing'];</body></html>";
            var fakeViewEngineHost = new FakeViewEngineHost();
            fakeViewEngineHost.GetTemplateCallback = (s, m) => "Hello @Context.Name";

            var result = viewEngine.Render(input, null, fakeViewEngineHost);

            Assert.Equal(@"<html><head></head><body>Hello Frank</body></html>", result);
        }
开发者ID:kppullin,项目名称:Nancy,代码行数:10,代码来源:SuperSimpleViewEngineTests.cs


注:本文中的Nancy.Tests.Fakes.FakeViewEngineHost类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。