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


C# ViewResult.ModelAs方法代码示例

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


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

示例1: modelas_in_actionresult_with_model_user_should_not_be_null

        public void modelas_in_actionresult_with_model_user_should_not_be_null()
        {
            ActionResult actionResult = new ViewResult
                                 {
                                     ViewData = new ViewDataDictionary(new User())
                                 };

            Assert.IsNotNull(actionResult.ModelAs<User>());
        }
开发者ID:vquaiato,项目名称:MVCTestsEx,代码行数:9,代码来源:ActionResultModelAsExtensionTests.cs

示例2: modelas_in_actionresult_with_model_ilist_with_2_users_second_user_with_name_should_have_the_name

        public void modelas_in_actionresult_with_model_ilist_with_2_users_second_user_with_name_should_have_the_name()
        {
            ActionResult actionResult = new ViewResult
                                 {
                                     ViewData = new ViewDataDictionary(new List<User> { new User(), new User { Name = "SomeName" } })
                                 };

            Assert.AreEqual("SomeName", actionResult.ModelAs<List<User>>()[1].Name);
        }
开发者ID:vquaiato,项目名称:MVCTestsEx,代码行数:9,代码来源:ActionResultModelAsExtensionTests.cs

示例3: modelas_in_actionresult_with_model_ilist_with_2_user_should_has_count_2

        public void modelas_in_actionresult_with_model_ilist_with_2_user_should_has_count_2()
        {
            ActionResult actionResult = new ViewResult
                                 {
                                     ViewData = new ViewDataDictionary(new List<User> { new User(), new User() })
                                 };

            Assert.AreEqual(2, actionResult.ModelAs<List<User>>().Count);
        }
开发者ID:vquaiato,项目名称:MVCTestsEx,代码行数:9,代码来源:ActionResultModelAsExtensionTests.cs

示例4: modelas_in_viewresult_with_model_ilist_with_1_user_with_name_should_have_the_name

        public void modelas_in_viewresult_with_model_ilist_with_1_user_with_name_should_have_the_name()
        {
            var viewResult = new ViewResult
                                 {
                                     ViewData = new ViewDataDictionary(new List<User> { new User { Name = "SomeName" } })
                                 };

            Assert.AreEqual("SomeName", viewResult.ModelAs<List<User>>()[0].Name);
        }
开发者ID:vquaiato,项目名称:MVCTestsEx,代码行数:9,代码来源:ViewResultModelAsExtensionTests.cs

示例5: modelas_in_viewresult_with_model_ilist_with_1_user_should_has_count_1

        public void modelas_in_viewresult_with_model_ilist_with_1_user_should_has_count_1()
        {
            var viewResult = new ViewResult
                                 {
                                     ViewData = new ViewDataDictionary(new List<User> { new User() })
                                 };

            Assert.AreEqual(1, viewResult.ModelAs<List<User>>().Count);
        }
开发者ID:vquaiato,项目名称:MVCTestsEx,代码行数:9,代码来源:ViewResultModelAsExtensionTests.cs

示例6: modelas_in_viewresult_with_model_ienumerable_user_should_not_be_null

        public void modelas_in_viewresult_with_model_ienumerable_user_should_not_be_null()
        {
            var viewResult = new ViewResult
                                 {
                                     ViewData = new ViewDataDictionary(new List<User>())
                                 };

            Assert.IsNotNull(viewResult.ModelAs<IEnumerable<User>>());
        }
开发者ID:vquaiato,项目名称:MVCTestsEx,代码行数:9,代码来源:ViewResultModelAsExtensionTests.cs

示例7: testing_that_modelas_in_viewresult_with_model_user_with_name_should_have_the_name

        public void testing_that_modelas_in_viewresult_with_model_user_with_name_should_have_the_name()
        {
            var viewResult = new ViewResult
                                 {
                                     ViewData = new ViewDataDictionary(new User { Name = "SomeName" })
                                 };

            Assert.AreEqual("SomeName", viewResult.ModelAs<User>().Name);
        }
开发者ID:vquaiato,项目名称:MVCTestsEx,代码行数:9,代码来源:ModelAsExtensionTests.cs

示例8: testing_that_modelas_in_viewresult_with_model_user_should_not_be_null

        public void testing_that_modelas_in_viewresult_with_model_user_should_not_be_null()
        {
            var viewResult = new ViewResult
                                 {
                                     ViewData = new ViewDataDictionary(new User())
                                 };

            Assert.IsNotNull(viewResult.ModelAs<User>());
        }
开发者ID:vquaiato,项目名称:MVCTestsEx,代码行数:9,代码来源:ModelAsExtensionTests.cs

示例9: modelas_in_actionresult_with_model_user_with_name_should_have_the_name

        public void modelas_in_actionresult_with_model_user_with_name_should_have_the_name()
        {
            ActionResult actionResult = new ViewResult
                                 {
                                     ViewData = new ViewDataDictionary(new User { Name = "SomeName" })
                                 };

            Assert.AreEqual("SomeName", actionResult.ModelAs<User>().Name);
        }
开发者ID:vquaiato,项目名称:MVCTestsEx,代码行数:9,代码来源:ActionResultModelAsExtensionTests.cs


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