Note that there are some explanatory texts on larger screens.

plurals
  1. POMvcContrib Test Helper problem
    text
    copied!<p>I am using MVC2 with MvcContrib HelpTester.</p> <p>I have problem with testing Controllers which are in Areas.</p> <p>Here is my Test class :</p> <pre><code>[TestFixture] public class RouteTests { [TestFixtureSetUp] public void Setup() { RouteTable.Routes.Clear(); MvcApplication.RegisterRoutes(RouteTable.Routes); } [Test] public void RootMatchesHome() { "~/".ShouldMapTo&lt;TradersSite.Controllers.HomeController&gt;(x =&gt; x.Index()); } [Test] public void AdminProductShouldMapToIndex() { "~/Admin/Produit/".ShouldMapTo&lt;TradersSite.Areas.Admin.Controllers.ProductController&gt;(x =&gt; x.Index()); } </code></pre> <p>Here's the action Index from my ProductController in the Admin Area : </p> <pre><code>public ActionResult Index(int? page) { int pageSize = 10; int startIndex = page.GetValueOrDefault() * pageSize; var products = _productRepository.GetAllProducts() .Skip(startIndex) .Take(pageSize); return View("Index", products); } </code></pre> <p>Here is the route map in my AdminAreaRefistration : </p> <pre><code>public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "Admin_default", "Admin/{controller}/{action}/{id}", new { action = "Index", id = UrlParameter.Optional } ); } </code></pre> <p>Finally here is the message I get back from MbUnit : </p> <p>[fixture-setup] success [failure] RouteTests.AdminProductShouldMapToIndex TestCase 'RouteTests.AdminProductShouldMapToIndex' failed: Expected Product but was Admin MvcContrib.TestHelper.AssertionException Message: Expected Product but was Admin Source: MvcContrib.TestHelper StackTrace: RouteTests.cs(44,0): at CBL.Traders.ControllerTests.RouteTests.AdminProductShouldMapToIndex()</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload