Bir birim testinde, bir denetleyici eyleminin gerçekten belirli bir sayfaya yönlendirdiğini doğrulamanın kolay bir yolu var mı?asp.net mv'de birim testi ile yönlendirmeyi doğrulayın
Kontrolör kodu:
public ActionResult Create(ProductModel newProduct)
{
this.repository.CreateProduct(newProduct);
return RedirectToAction("Index");
}
Yani benim testte, ben kontrolör aslında yönlendirme olduğunu doğrulamak gerekir.
ProductController controller = new ProductController(repository);
RedirectToRouteResult result = (RedirectToRouteResult)controller.Create(newProduct);
bool redirected = checkGoesHere;
Assert.True(redirected, "Should have redirected to 'Index'");
Doğrulama işlemini nasıl yapacağınızdan emin değilim. Herhangi bir fikir?
Teşekkür Darin ...
Umut böyle bir şey yapabilirsiniz. TestHelper –
+1 Bu MvcContrib kütüphanesi harika! –
Link için – will