mvccontrib-testhelper

Making mvccontrib testhelper work with actions that get route data automapped to objects

This is ASP.NET MVC v1 (not using the v2 yet) I have a route entry like this: routes.MapRoute( "Srp", "soeg-{searchQuery}/{listingType}", new { controller = "Srp", action = "Search", listingType = string.Empty }, new { listingType = "privat|forhandler|"} ); and a...

how to test asp.net mvc post actions using MvcContrib.TestHelper

I am trying to test my routing configuration using the excellent MvcContrib.TestHelper and I've run into a problem. Please assume that my Routing Configuration is set up correctly and initialised in the TestFixture. I have a controller (TransactionsController) action called Create that takes an input parameter of type TransactionReco...

Need help with error using MvcContrib.TestHelper's ShouldMapTo() generic extension method

I'm trying to unit test my routes using the MvcContrib.TestHelper ShouldMapTo<TController>() extension method, but my tests fail with the following error message: failed: Method MvcContrib.TestHelper.RouteTestingExtensions.ShouldMapTo: type argument 'ReviewController' violates the constraint of type parameter 'TController'. But Review...

Unit Testing UrlHelper Extension Methods

I'm trying to create unit tests to make sure my extension methods for UrlHelper work? Does anyone know how to do this? I'm using MVC 1.0 and MvcContrib. I can test the routes but can't test code like this: public static string MoreFloorplans(this UrlHelper urlHelper, long productID, int pageIndex) { return urlHelper.Acti...

How can I test route/action resolution of URL with query string?

I'm trying to use code such as the following in my unit tests, /* Test setup code */ _routes = RouteTable.Routes; MvcApplication.RegisterRoutes(_routes); //set up the routes as they would be in actual application /* test code */ Expression<Func<SearchController, ActionResult>> actionFunc; actionFunc = action => action.Results("x", 3, nu...

Newbie question on MvcContrib TestHelpers

Hi, I'm just starting to use the TestHelpers in MvcContrib. I want to try and test an action method on my controller that itself tests if IsAjaxRequest() is true. I've used the same code that is shown in the TestHelper samples to set up the TestControllerBuilder _controller = new StarsController(); _builder = new TestControllerBu...

Error using MVCContrib TestHelper

While trying to implement the second answer to a previous question, I am receiving an error. I have implemented the methods just as the post shows, and the first three work properly. The fourth one (HomeController_Delete_Action_Handler_Should_Redirect_If_Model_Successfully_Delete) gives this error: Could not find a parameter named 'con...

After using Automapper to map a ViewModel how and what should I test?

I am attempting to test the Index action of a controller. The action uses AutoMapper to map a domain Customer object to a view model TestCustomerForm. While this works I am concerned about the best way to test the results that I am receiving from the Index action. The controller's index action looks like this: public ActionResult Index...

Trying to stub Server.MapPath with MvcContrib Test helpers and Rhino Mocks 3.5

Hi, I'm using MvcContrib's test helpers and Rhino Mocks 3.5 to test an ASP.NET MVC action method. I build my fake controller like so: var _builder = new TestControllerBuilder(); _builder.InitializeController(_controller); So I get a fake controller that contains fake HTTP Server etc. I'm then trying to stub the Server.MapPath method...

MvcContrib TestHelpers don't seem to provide a full HTTPContext.Server object

So the MvcContrib TestHelpers create mock versions of the following HttpContext HttpRequest HttpResponse HttpSession Form TempData QueryString ApplicationPath PathInfo within a fake controller when using this kind of code var _controller = new FooController(); var _builder = new TestControllerBuilder(); _builder.InitializeC...

Using MVCContrib.TestHelpers with MsTest - is there any way to get nicer fail messages?

I'm just starting to use MVCContrib, and I'm really liking the syntactic sugar it adds to various test scenarious. For example, I just wrote this assertion: "~/".Route().ShouldMapTo<SpotController>(c => c.List()); It's brilliant! Well, almost... Instead of, as I'd like, seeing the actual reason why the test fails (I've changed nothin...

How do I test rendered views when using T4MVC with TestHelper?

How do I test which view was rendered from a controller action if what I get is a T4MVC_ActionResult? Under normal circumstances I should be able to directly use TestHelper's methods, like in the examples: pooController.Details().AssertViewRendered().ForView("Details") ...but, since through T4MVC I get a T4MVC_ActionResult instead of ...

SelectListItemNotFound Exception using MvcContrib.TestHelper.WatiN with SelectList

When I try to use the MvcContrib.TestHelper.WatiN API to conduct UI unit testing that utilizes AJAX to populate select lists, I receive a SelectListItemNotFound Exception. Aside from using a Sleep statement, is there some way of "pausing" until the list is filled? The link, http://pushpontech.blogspot.com/2008/04/ajax-issues-with-watin...

Testing radio buttons using MvcContrib.TestHelper.WatiN

I've been able to use MvcContrib.TestHelper.WatiN to unit test textboxes and drop-downs, but have been unable to get it to work with radio buttons. I keep getting an exception stating that the HTML Element cannot be found, however, I've checked and the name is correct in the source. Does anyone know of an example using MvcContrib.TestH...

Missing Documentation: MVCContrib UI-Testing

Is there any documentation or example how to use MvcContrib.TestHelper.Ui and WatinDriver? ...

Issue with mvcContrib fluent route testing in asp.net mvc

I have an issue with testing routes using the MVCContrib Fluent route testing. The test fails yet the application recognises the routes. Let me explain.... I have the following routes in my register (shown in order) routes.MapRoute( "PurchaseUnitsPaged", "PurchaseUnits/Page{page}", new {...