本文整理汇总了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>());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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>>());
}
示例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);
}
示例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>());
}
示例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);
}