I currently have the requirement to set the Request.AcceptTypes property for a controller test. AFAIK there is currently no way of doing this within the MVC-Contrib TestControllerBuilder.
I updated their latest trunk and have created a patch file in case you, or the MVC-Contrib guys want to use it.
Heres the test:
[Test]
public void CanSpecifyRequestAcceptTypes()
{
builder.AcceptTypes = new[] {"some/type-extension"};
var controller = new TestHelperController();
builder.InitializeController(controller);
Assert.That(controller.HttpContext.Request.AcceptTypes, Is.Not.Null);
Assert.That(controller.HttpContext.Request.AcceptTypes.Length, Is.EqualTo(1));
Assert.That(controller.HttpContext.Request.AcceptTypes[0], Is.EqualTo("some/type-extension"));
}
Heres the code
protected void SetupHttpContext()
{
...
SetupResult.For(request.AcceptTypes).Do((Func<string[]>)(() => AcceptTypes));
.....
}
Download the patch: click here
Dave the Ninja