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


C# ViewResult.WithViewData方法代码示例

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


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

示例1: WithViewData_should_throw_if_view_data_type_does_not_match

        public void WithViewData_should_throw_if_view_data_type_does_not_match()
        {
            const string wrongViewDataType = "WrongType";
            var result = new ViewResult { ViewData = new ViewDataDictionary(wrongViewDataType)};

            result.WithViewData<CustomReferenceTypeViewData>();
        }
开发者ID:EagleFlyHigh,项目名称:MvcContrib,代码行数:7,代码来源:ActionResultHelperTester.cs

示例2: WithViewData_should_throw_exception_if_view_data_is_null_and_expected_type_is_value_type

        public void WithViewData_should_throw_exception_if_view_data_is_null_and_expected_type_is_value_type()
        {
            var renderResult = new ViewResult {ViewData = new ViewDataDictionary<CustomReferenceTypeViewData>() };

            renderResult.WithViewData<CustomValueTypeViewData>();
        }
开发者ID:EagleFlyHigh,项目名称:MvcContrib,代码行数:6,代码来源:ActionResultHelperTester.cs

示例3: WithViewData_should_return_view_data_if_view_data_type_is_implementation_of_generic_interface

        public void WithViewData_should_return_view_data_if_view_data_type_is_implementation_of_generic_interface()
        {
            var expectedData = new List<string> { "a", "b", "c" };
            var renderResult = new ViewResult { ViewData = new ViewDataDictionary(expectedData) };

            var result = renderResult.WithViewData<IList<string>>();

            Assert.That(result, Is.EqualTo(expectedData));
        }
开发者ID:EagleFlyHigh,项目名称:MvcContrib,代码行数:9,代码来源:ActionResultHelperTester.cs

示例4: WithViewData_should_return_view_data_if_view_data_type_matches

        public void WithViewData_should_return_view_data_if_view_data_type_matches()
        {
            var expectedData = new CustomReferenceTypeViewData {ID = 2, Name = "Foo"};
            var renderResult = new ViewResult {ViewData = new ViewDataDictionary(expectedData)};

            var result = renderResult.WithViewData<CustomReferenceTypeViewData>();

            Assert.That(result, Is.EqualTo(expectedData));
        }
开发者ID:EagleFlyHigh,项目名称:MvcContrib,代码行数:9,代码来源:ActionResultHelperTester.cs

示例5: WithViewData_should_return_null_if_view_data_is_null_and_expected_type_is_reference_type

        public void WithViewData_should_return_null_if_view_data_is_null_and_expected_type_is_reference_type()
        {
            var renderResult = new ViewResult {ViewData = new ViewDataDictionary<CustomReferenceTypeViewData>() };

            var result = renderResult.WithViewData<CustomReferenceTypeViewData>();

            Assert.That(result, Is.Null);
        }
开发者ID:EagleFlyHigh,项目名称:MvcContrib,代码行数:8,代码来源:ActionResultHelperTester.cs


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