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


C# FormContext.RenderedField方法代码示例

本文整理汇总了C#中FormContext.RenderedField方法的典型用法代码示例。如果您正苦于以下问题:C# FormContext.RenderedField方法的具体用法?C# FormContext.RenderedField怎么用?C# FormContext.RenderedField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormContext的用法示例。


在下文中一共展示了FormContext.RenderedField方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetUnobtrusiveValidationAttributesMarksRenderedFieldsWithFullName

        public void GetUnobtrusiveValidationAttributesMarksRenderedFieldsWithFullName()
        {
            // Arrange
            var formContext = new FormContext();
            var viewContext = new Mock<ViewContext>();
            var viewData = new ViewDataDictionary();
            viewContext.SetupGet(vc => vc.FormContext).Returns(formContext);
            viewContext.SetupGet(vc => vc.ClientValidationEnabled).Returns(true);
            viewContext.SetupGet(vc => vc.UnobtrusiveJavaScriptEnabled).Returns(true);
            viewData.TemplateInfo.HtmlFieldPrefix = "Prefix";
            var viewDataContainer = MvcHelper.GetViewDataContainer(viewData);
            var htmlHelper = new HtmlHelper(viewContext.Object, viewDataContainer);

            // Act
            htmlHelper.GetUnobtrusiveValidationAttributes("foobar");

            // Assert
            Assert.False(formContext.RenderedField("foobar"));
            Assert.True(formContext.RenderedField("Prefix.foobar"));
        }
开发者ID:tlycken,项目名称:aspnetwebstack,代码行数:20,代码来源:HtmlHelperTest.cs

示例2: GetUnobtrusiveValidationAttributesReturnsEmptySetAndSetsFieldAsRenderedForFieldWithNoClientRules

        public void GetUnobtrusiveValidationAttributesReturnsEmptySetAndSetsFieldAsRenderedForFieldWithNoClientRules()
        {
            // Arrange
            var formContext = new FormContext();
            var viewContext = new Mock<ViewContext>();
            viewContext.SetupGet(vc => vc.FormContext).Returns(formContext);
            viewContext.SetupGet(vc => vc.ClientValidationEnabled).Returns(true);
            viewContext.SetupGet(vc => vc.UnobtrusiveJavaScriptEnabled).Returns(true);
            var viewDataContainer = MvcHelper.GetViewDataContainer(new ViewDataDictionary());
            var htmlHelper = new HtmlHelper(viewContext.Object, viewDataContainer);
            htmlHelper.ClientValidationRuleFactory = delegate { return Enumerable.Empty<ModelClientValidationRule>(); };

            // Act
            IDictionary<string, object> result = htmlHelper.GetUnobtrusiveValidationAttributes("foobar");

            // Assert
            Assert.Empty(result);
            Assert.True(formContext.RenderedField("foobar"));
        }
开发者ID:tlycken,项目名称:aspnetwebstack,代码行数:19,代码来源:HtmlHelperTest.cs

示例3: GetUnobtrusiveValidationAttributesReturnsEmptySetWhenFieldHasAlreadyBeenRendered

        public void GetUnobtrusiveValidationAttributesReturnsEmptySetWhenFieldHasAlreadyBeenRendered()
        {
            // Arrange
            var formContext = new FormContext();
            formContext.RenderedField("foobar", true);
            var viewContext = new Mock<ViewContext>();
            viewContext.SetupGet(vc => vc.FormContext).Returns(formContext);
            viewContext.SetupGet(vc => vc.ClientValidationEnabled).Returns(true);
            viewContext.SetupGet(vc => vc.UnobtrusiveJavaScriptEnabled).Returns(true);
            var viewDataContainer = MvcHelper.GetViewDataContainer(new ViewDataDictionary());
            var htmlHelper = new HtmlHelper(viewContext.Object, viewDataContainer);

            // Act
            IDictionary<string, object> result = htmlHelper.GetUnobtrusiveValidationAttributes("foobar");

            // Assert
            Assert.Empty(result);
        }
开发者ID:tlycken,项目名称:aspnetwebstack,代码行数:18,代码来源:HtmlHelperTest.cs

示例4: CanSetRenderedFieldToBeTrue

        public void CanSetRenderedFieldToBeTrue()
        {
            // Arrange
            var context = new FormContext();
            var name = Guid.NewGuid().ToString();
            context.RenderedField(name, true);

            // Act
            bool result = context.RenderedField(name);

            // Assert
            Assert.True(result);
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:13,代码来源:FormContextTest.cs

示例5: RenderedFieldIsFalseByDefault

        public void RenderedFieldIsFalseByDefault()
        {
            // Arrange
            var context = new FormContext();

            // Act
            bool result = context.RenderedField(Guid.NewGuid().ToString());

            // Assert
            Assert.False(result);
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:11,代码来源:FormContextTest.cs

示例6: GetUnobtrusiveValidationAttributesReturnsEmptySetWhenClientValidationIsNotEnabled

        public void GetUnobtrusiveValidationAttributesReturnsEmptySetWhenClientValidationIsNotEnabled() {
            // Arrange
            var formContext = new FormContext();
            formContext.RenderedField("foobar", true);
            var viewContext = new Mock<ViewContext>();
            viewContext.SetupGet(vc => vc.FormContext).Returns(formContext);
            var viewDataContainer = MvcHelper.GetViewDataContainer(new ViewDataDictionary());
            var htmlHelper = new HtmlHelper(viewContext.Object, viewDataContainer);

            // Act
            IDictionary<string, object> result = htmlHelper.GetUnobtrusiveValidationAttributes("foobar");

            // Assert
            Assert.AreEqual(0, result.Count);
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:15,代码来源:HtmlHelperTest.cs


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