Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
F# wrapper for having AutoFixture perform post-processing on AutoFixture Specimens of a given type
type TypeThatIsARequestSpecification<'T>() =
interface IRequestSpecification with
member this.IsSatisfiedBy request =
match request with
| :? System.Type as requestType -> typeof<'T>.IsAssignableFrom( requestType)
| _ -> false
type PrepareSpecimenCommand<'T>( action) =
interface ISpecimenCommand with
member this.Execute( specimen, context) =
let instance = specimen :?> 'T
action instance
type WarmupCustomization<'T>( prepareAction) =
interface ICustomization with
member this.Customize fixture =
fixture.Customizations.Add(
new FilteringSpecimenBuilder(
Postprocessor(
MethodInvoker(
ModestConstructorQuery()),
PrepareSpecimenCommand<'T>( prepareAction)),
TypeThatIsARequestSpecification<'T>()))
type Context() as this =
inherit AutoDataAttribute()
let initializeSut (sut:IDynamicAllocationCache) =
sut.Purge()
do this.Fixture.Customize <| WarmupCustomization initializeSut |> ignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.