This might just be me not using it properly but having some issues using ruleset functionality. I get a MissingMethodException (No parameterless constructor defined for this object) in the below example when I expect it to function just the same as the generate call without the ruleset name but to use an age of 65 rather than the default of 18. It is intentional that Age is only accessible via a private setter and not exposed in the constructor.
void Main()
{
var personFaker = new PersonFaker();
var defaultPerson = personFaker.Generate(); // No issues
var oldPerson = personFaker.Generate("OldAge"); //No parameterless constructor defined for this object exception.
}
public sealed class PersonFaker : AutoFaker<Person>
{
public PersonFaker()
{
RuleFor(x => x.Age, () => 18);
RuleSet("OldAge", set =>
{
set.RuleFor(x => x.Age, () => 65);
});
}
}
public class Person
{
public Person(string name)
{
Name = name;
}
public string Name { get; private set; }
public int Age { get; private set; }
}
This might just be me not using it properly but having some issues using ruleset functionality. I get a MissingMethodException (No parameterless constructor defined for this object) in the below example when I expect it to function just the same as the generate call without the ruleset name but to use an age of 65 rather than the default of 18. It is intentional that Age is only accessible via a private setter and not exposed in the constructor.