[HttpGet]
[Authorize]
public ActionResult Create() //loads the form
{
var categoryList = new SelectList(new[] { "Electronics", "Toys","Books","Sporting Goods"}); //defines the categories
ViewBag.CategoryList = categoryList;
return View();
}
我为此写了一个测试方法..
[TestMethod]
public void TestCreate() {
AdvertisementController controller = new AdvertisementController();
var categoryList = new SelectList(new[] { "Electronics", "Toys", "Books", "Sporting Goods" });
ViewResult result = controller.Create() as ViewResult;
Assert.AreEqual(categoryList,result.ViewBag.categoryList);
}
但它失败了。我想知道这是怎么回事。这有什么问题??