Skip to content

Instantly share code, notes, and snippets.

@ploeh
Created March 22, 2014 07:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ploeh/9702672 to your computer and use it in GitHub Desktop.
Save ploeh/9702672 to your computer and use it in GitHub Desktop.
ASP.NET Web API 2 ApiController AutoFixture Customization
type ApiControllerCustomization() =
let controllerSpecification =
{ new IRequestSpecification with
member this.IsSatisfiedBy request =
match request with
| :? Type as t when typeof<ApiController>.IsAssignableFrom t ->
true
| _ -> false }
interface ICustomization with
member this.Customize fixture =
fixture.Customizations.Add(
FilteringSpecimenBuilder(
MethodInvoker(
ModestConstructorQuery()),
controllerSpecification))
@ploeh
Copy link
Author

ploeh commented Mar 22, 2014

The only thing this really does is to ensure that all ApiControllers are created by AutoFixture without AutoProperties...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment