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


C# ViewResult.AssertModelStateError方法代码示例

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


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

示例1: Should_blow_up_if_model_state_does_not_have_key_for_exception

        public void Should_blow_up_if_model_state_does_not_have_key_for_exception()
        {
            var viewDataDictionary = new ViewDataDictionary();

            var result = new ViewResult {
                ViewData = viewDataDictionary
            };

            result.AssertModelStateError<Exception>("foo", 0);
        }
开发者ID:tmont,项目名称:mvc-testing-helpers,代码行数:10,代码来源:ActionResultExtensionTests.cs

示例2: Should_blow_up_if_model_state_does_not_have_exception_at_specified_index

        public void Should_blow_up_if_model_state_does_not_have_exception_at_specified_index()
        {
            var viewDataDictionary = new ViewDataDictionary();
            viewDataDictionary.ModelState.AddModelError("foo", new Exception());

            var result = new ViewResult {
                ViewData = viewDataDictionary
            };

            result.AssertModelStateError<Exception>("foo", 1);
        }
开发者ID:tmont,项目名称:mvc-testing-helpers,代码行数:11,代码来源:ActionResultExtensionTests.cs

示例3: Should_blow_up_if_model_state_does_not_have_error_at_specified_index

        public void Should_blow_up_if_model_state_does_not_have_error_at_specified_index()
        {
            var viewDataDictionary = new ViewDataDictionary();
            viewDataDictionary.ModelState.AddModelError("foo", "error message");

            var result = new ViewResult {
                ViewData = viewDataDictionary
            };

            result.AssertModelStateError("foo", 1, "foo");
        }
开发者ID:tmont,项目名称:mvc-testing-helpers,代码行数:11,代码来源:ActionResultExtensionTests.cs

示例4: Should_blow_up_if_model_state_exceptions_do_not_match

        public void Should_blow_up_if_model_state_exceptions_do_not_match()
        {
            var viewDataDictionary = new ViewDataDictionary();
            viewDataDictionary.ModelState.AddModelError("foo", new ArgumentException());

            var result = new ViewResult {
                ViewData = viewDataDictionary
            };

            result.AssertModelStateError<ArgumentNullException>("foo", 0);
        }
开发者ID:tmont,项目名称:mvc-testing-helpers,代码行数:11,代码来源:ActionResultExtensionTests.cs

示例5: Should_blow_up_if_model_state_error_message_do_not_match

        public void Should_blow_up_if_model_state_error_message_do_not_match()
        {
            var viewDataDictionary = new ViewDataDictionary();
            viewDataDictionary.ModelState.AddModelError("foo", "error message");

            var result = new ViewResult {
                ViewData = viewDataDictionary
            };

            result.AssertModelStateError("foo", 0, "not the correct message");
        }
开发者ID:tmont,项目名称:mvc-testing-helpers,代码行数:11,代码来源:ActionResultExtensionTests.cs

示例6: Should_verify_model_state_exception

        public void Should_verify_model_state_exception()
        {
            var viewDataDictionary = new ViewDataDictionary();
            viewDataDictionary.ModelState.AddModelError("foo", new ArgumentException());

            var result = new ViewResult {
                ViewData = viewDataDictionary
            };

            result.AssertModelStateError<ArgumentException>("foo", 0);
        }
开发者ID:tmont,项目名称:mvc-testing-helpers,代码行数:11,代码来源:ActionResultExtensionTests.cs

示例7: Should_verify_model_error_message

        public void Should_verify_model_error_message()
        {
            var viewDataDictionary = new ViewDataDictionary();
            viewDataDictionary.ModelState.AddModelError("foo", "error message");

            var result = new ViewResult {
                ViewData = viewDataDictionary
            };

            result.AssertModelStateError("foo", 0, "error message");
        }
开发者ID:tmont,项目名称:mvc-testing-helpers,代码行数:11,代码来源:ActionResultExtensionTests.cs


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