I am trying to auto mock ApiController class in my test cases. It worked perfectly when I was using WebApi1. I started to use WebApi2 on the new project and I am getting thi
Based on Nikos' answer:
This is a more generic way of using this customization where the controller type can be supplied and the Customization can be used for any controller
internal class WebApiCustomization : ICustomization
where TControllerType : ApiController
{
public void Customize(IFixture fixture)
{
fixture.Customize(c => c
.Without(x => x.Content)
.Do(x => x.Properties[HttpPropertyKeys.HttpConfigurationKey] =
new HttpConfiguration()));
fixture.Customize(c => c
.OmitAutoProperties()
.With(x => x.Request, fixture.Create()));
}
}
Then use as follows:
var fixture = new Fixture().Customize(
new WebApiCustomization());
var sut = fixture.Create();