Extending AutoFixture
Specimen builders
public interface ISpecimenBuilder
{
object Create(object request, ISpecimenContext context);
}public class SampleValueObject
{
public string StringValue { get; set; }
public int IntValue { get; set; }
}
public class SampleValueObjectSpecimenBuilder : ISpecimenBuilder
{
public object Create(object request, ISpecimenContext context)
{
if (request is Type type && type == typeof(SampleValueObject))
{
return new SampleValueObject
{
StringValue = context.Resolve(typeof(string)) as string,
IntValue = 42
};
}
return new NoSpecimen();
}
}Behaviors
Customizations
Last updated