Skip to content

Instantly share code, notes, and snippets.

@NullEntity
Created November 23, 2017 00:21
Show Gist options
  • Save NullEntity/49974d1560554b61ef7800597e0e3c74 to your computer and use it in GitHub Desktop.
Save NullEntity/49974d1560554b61ef7800597e0e3c74 to your computer and use it in GitHub Desktop.
public class PostActionTransformation<T> : ISpecimenBuilderTransformation
{
private readonly List<ISpecimenCommand> _commands = new List<ISpecimenCommand>();
public ISpecimenBuilder Transform(ISpecimenBuilder builder)
{
return new Postprocessor(
builder,
new CompositeSpecimenCommand(_commands),
new IsAssignableToTypeSpecification(typeof(T)));
}
public PostActionTransformation<T> With<TProperty>(Expression<Func<T, TProperty>> propertyPicker,
TProperty value)
{
_commands.Add(new BindingCommand<T, TProperty>(propertyPicker, value));
return this;
}
public PostActionTransformation<T> Do(Action<T, ISpecimenContext> func)
{
_commands.Add(new ActionSpecimenCommand<T>(func));
return this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment