I have a solution with differents projects in it, One those is an MVC 3 project, and the other is a test project.
From the test project, I'm trying to test my controllers behavior. But when I'm running a test the system throws an error telling me this:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
WRN: Assembly binding logging is turned OFF.To enable assembly bind failure logging, set the registry value[HKLM\Software\Microsoft\Fusion!EnableLog](DWORD) to 1.
The code from the test os the following:
[TestMethod]
public void TestMethod()
{
var myService = new Mock<IMyService>();
myService.Setup(a => a.ReadAuthorizationRequest())
.Returns<EndUserAuthorizationRequest>(null);
int error = 0;
var controller = new myController(myService.Object);
try
{
var actionResult = controller.Authorize();
}
catch (HttpException exception)
{
error = exception.GetHttpCode();
}
Assert.AreEqual(403, error);
}
the controller:
public class myController: Controller
{
private readonly IMyService _service;
public OAuthController(IMyService service)
{
_service = service;
}
[Authorize, AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
public ActionResult Authorize()
{
ClientApplication requestingClient;
var request = _service.ReadAuthorizationRequest();
if (request == null)
{
throw new HttpException((int) HttpStatusCode.BadRequest,
"Missing authorization request.");
}
}
}
As you can see, I'm trying to test the controller behavior, so that, whenever the service doesn't read the request the controller should throw an httpException with httpStatusCode 403.
What is wrong with this. Thank you in advance.