Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Reflection;
- using Ploeh.AutoFixture.Kernel;
- namespace AutofixtureDemo
- {
- public class ContinuousAutoIdSpecimenBuilder : ISpecimenBuilder
- {
- private int _nextId;
- public ContinuousAutoIdSpecimenBuilder()
- : this(1)
- {
- }
- public ContinuousAutoIdSpecimenBuilder(int start)
- {
- _nextId = start;
- }
- public object Create(object request, ISpecimenContext context)
- {
- var pi = request as PropertyInfo;
- if (pi != null && pi.Name.Equals("Id") && pi.PropertyType == typeof(int))
- {
- return _nextId++;
- }
- return new NoSpecimen(request);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement