Reputation: 776
I've created a new test project in a pre-existing Visual Studio solution and attempting to mock a controller so I can test routing. The main project makes use of Combres for minification of css etc. To better demonstrate the problem I've put the .AddCombresRoute into the test which generates the error I'm trying to solve.
private HttpContextBase rmContext;
private HttpRequestBase rmRequest;
[TestInitialize]
public void SetupTests()
{
// Setup Rhino Mocks
rmContext = MockRepository.GenerateMock<HttpContextBase>();
rmRequest = MockRepository.GenerateMock<HttpRequestBase>();
rmContext.Stub(x => x.Request).Return(rmRequest);
}
[TestMethod]
public void RhinoMocksRoutingTest()
{
// Arrange
RouteCollection routes = new RouteCollection();
RouteConfig.RegisterRoutes(routes);
rmRequest.Stub(e => e.AppRelativeCurrentExecutionFilePath).Return("~/Home/Index");
// Act
routes.AddCombresRoute("Combres Route"); *** ERRROR HERE ***
RouteData routeData = routes.GetRouteData(rmContext);
// Assert
Assert.IsNotNull(routeData);
Assert.AreEqual("Home",routeData.Values["controller"]);
Assert.AreEqual("Index",routeData.Values["action"]);
}
Despite making the correct references, ensuring combres.xml and combres.xsd are in App_Data (and copied to local) and dropping in the relevant entries into app.config I get the following error when I run the test:
ArgumentNullException was unhandled by user code. An exception of type 'System.ArgumentNullException' occurred in System.Xml.dll was not handled in user code. Additional information: Value cannot be null.
Upvotes: 0
Views: 71