Search code examples
c#unit-testingnbuilder

NBuilder start integer at 0


I have this model:

public class OrderProperty
{
    [Required] public int Id { get; set; }
    [Required] public int Order { get; set; }
}

The Order property starts at 0 instead of 1. When I use NBuilder to build me a list of OrderProperties, it automatically sets the first Order to 1

Builder<OrderProperty>.CreateListOfSize(10).Build().ToList()

Is there a way to tell it to start from 0 instead?


Solution

  • you can do simply like this.

    Builder<OrderProperty>.CreateListOfSize(10).All().With(x => x.Order -=1).Build().ToList();