Due to introducing C# 8's non-nullable reference types to my codebase, I'm changing my domain classes to have constructors that accept parameters to initialize values of their non-nullable properties.
In unit tests I don't want to bother with filling these constructor parameters with meaningless data, so I tried using libraries like NBuilder and Bogus to create instances for me. Bogus example is var myObject = Faker.Generate<MyClass>();
.
However, looks like both Bogus and NBuilder expect my classes to have parameterless constructors or to write some configuration code for my class. They can't just discover my constructor and call it with generated parameter values. When asked Bogus creator, I was responded that they don't handle this situation on purpose because of possible ambiguity when there is more than one constructor. But I don't mind if a framework uses some default behaviour for picking a constructor (e.g. take the one which has the most parameters).
So, is there a library that would discover and use constructors when generating objects?