Configuration
NBuilder allows you to change its default behaviour using the BuilderSetup class.
Specifying a custom persistence service
You can completely replace the default persistence service with your own. All you need to do is inherit from IPersistenceService and specify it using BuilderSetup.SetPersistenceService()
BuilderSetup.SetPersistenceService(new MyCustomPersistenceService());
Specifying a custom property namer
You can specify a different property namer. Out of the box the ones available are the default SequentialPropertyNamer and the RandomValuePropertyNamer
var namer = new RandomValuePropertyNamer(new RandomGenerator(),
new ReflectionUtil(),
true,
DateTime.Now,
DateTime.Now.AddDays(10),
true);
BuilderSetup.SetDefaultPropertyNamer(namer);
Setting a property namer for a specific type
If you need to override the property naming for a particular type you can use the SetPropertyNamerFor<T> method.
BuilderSetup.SetPropertyNamerFor<Product>(
new CustomProductPropertyNamer(new ReflectionUtil()));
Disabling property naming for an individual property
You can switch off property naming using the DisablePropertyNamingFor() method
BuilderSetup.DisablePropertyNamingFor<Product, int>(x => x.Id);

