Questions tagged [mvccontrib-testhelper]

42 questions
13
votes
1 answer

Looking for direction on unit testing a controller extension that renders a partial view

As the title says, I'm looking for direction on how to properly test a controller extension. The extension renders a partial view which in turn I'm using within a JSONResult: public static string RenderPartialViewToString(this Controller…
Jesse
  • 8,223
  • 6
  • 49
  • 81
11
votes
2 answers

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…
ahsteele
  • 26,243
  • 28
  • 134
  • 248
10
votes
1 answer

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() extension method, but my tests fail with the following error message: failed: Method MvcContrib.TestHelper.RouteTestingExtensions.ShouldMapTo: type argument…
7
votes
3 answers

MvcContrib TestHelper giving an odd error when using AssertViewRendered

I am trying to use the MvcContrib Test Helper to test a controller method in MVC3. The controller: public class HomeController : Controller { public ActionResult Index() { return View(); } } The test: [TestMethod] public void…
Ali
  • 258
  • 2
  • 9
6
votes
1 answer

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…
Graza
  • 5,010
  • 6
  • 32
  • 37
5
votes
2 answers

Why does mvccontrib's AssertViewRendered().ForView("Edit") fail due to view name being full cshtml path?

I have the following unit test: [TestMethod] public void Add_Returns_Edit_View() { // Act ActionResult result = _controller.Add(); // Verify result.AssertViewRendered().ForView("Edit"); } This should…
KallDrexx
  • 27,229
  • 33
  • 143
  • 254
5
votes
1 answer

anyway to install mvccontrib.testhelper with nuget

I have installed mvccontrib using nuget with the usual install-package mvccontrib, but i notice there is no testhelper there. Is there some other way or flag that i have to use to install it. Trying install-package mvccontrib.testhelper doesn't…
paddymurf
  • 53
  • 2
4
votes
2 answers

Using MvcContrib TestHelper to assert that an inbound route should not be mapped

Looked for a method on the MvcContrib.TestHelper.RouteTestingExtensions class named ShouldNotMap. There is ShouldBeIgnored, but I don't want to test an IgnoreRoute invocation. I want to test that a specific incoming route should not be mapped to any…
danludwig
  • 46,965
  • 25
  • 159
  • 237
3
votes
2 answers

How do I test the default view when using T4MVC with MvcContrib.TestHelper AssertViewRendered

I am using T4MVC in my ASP.NET MVC 3 project. I have the following basic test: [TestMethod] public void IndexReturnsIndexView() { var controller = new HomeController(); var result = controller.Index(); …
Rebecca
  • 13,914
  • 10
  • 95
  • 136
3
votes
1 answer

Mvcontrib.MVC3.Testhelper UpdateModel NullReferenceExceuption during Unit Test

I am trying to unit test an edit action on my controller in ASP.NET MVC 3. I have installed Mvcontrib.MVC3.TestHelper via nuget to mock out my controller Context but I am still getting a NullReferenceException my code looks like this: [TestMethod] …
3
votes
2 answers

Unit Test Controller with PerWebRequest LifeStyle dependency

I am trying to write a unit test for a controller that has a dependency on a type whose lifestyle is "PerWebRequest". Castle throws the following exception: System.InvalidOperationException: HttpContext.Current is null. PerWebRequestLifestyle can…
Nick
  • 19,198
  • 51
  • 185
  • 312
3
votes
1 answer

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…
2
votes
1 answer

MVCContrib TestHelper problem with session.clear, session.abandon and Rhino Mock

Hi I'm trying to unit test my logout action on my controller but I have hard times to test or stub my Session in the HttpContext. I'm using MVC Contrib TestHelper to make it easier but now I need a little help. Here's my test : [TestFixture] …
VinnyG
  • 6,883
  • 7
  • 58
  • 76
2
votes
1 answer

Issue with MvcContrib TestHelper Fluent Route Testing and Specific HttpVerbs

I'm attempting to use the MvcContrib TestHelper fluent route testing API, but I'm seeing odd behavior. The .WithMethod(HttpVerb) extension method does not seem to be executing as expected. Here's my controller showing (2) actions (identically…
Danny Douglass
  • 390
  • 1
  • 11
2
votes
1 answer

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…
Kenji Kina
  • 2,402
  • 3
  • 22
  • 39
1
2 3