Exemplo n.º 1
0
        public void ProfileWithNesteds()
        {
            HtmlConventionFactory.Add(new DefaultHtmlConventions());
            HtmlConventionFactory.Add(new DataAnnotationHtmlConventions());

            var model = new ProfileViewModel() { Name = "Test" };
            var helper = MvcMockHelpers.GetHtmlHelper(model);

            using (helper.Profile(new ProfileTest1()))
            {
                var tag = helper.Input(x => x.Name);
                tag.ToHtmlString().ShouldBe("<profile>Test</profile>");

                using (helper.Profile(new ProfileTest2()))
                {
                    var tag3 = helper.Input(x => x.Name);
                    tag3.ToHtmlString().ShouldBe("<profilenested>Test</profilenested>");
                }

                var tag2 = helper.Input(x => x.Name);
                tag2.ToHtmlString().ShouldBe("<profile>Test</profile>");
            }

            var tag1 = helper.Input(x => x.Name);
            tag1.ToHtmlString().ShouldBe("<input type=\"text\" value=\"Test\" id=\"Name\" name=\"Name\" />");
        }
Exemplo n.º 2
0
        public void ProfileBasic()
        {
            HtmlConventionFactory.Add(new DefaultHtmlConventions());
            HtmlConventionFactory.Add(new DataAnnotationHtmlConventions());

            var model = new ProfileViewModel() { Name = "Test" };
            var helper = MvcMockHelpers.GetHtmlHelper(model);

            helper.Profile(new ProfileTest1());

            var tag = helper.Input(x => x.Name);
            tag.ToHtmlString().ShouldBe("<profile>Test</profile>");
        }