I'm trying the next rule :
var result = new AutoFaker<MyModel>().RuleFor(x => x.AnotherModel, null).Generate();
public class MyModel
{
public string Test { get; set; }
public AnotherModel AnotherModel { get; set; }
}
public class AnotherModel
{
public string Test1 { get; set; }
}
Got the message :
Severity Code Description Project File Line Suppression State
Error CS0121 The call is ambiguous between the following methods or properties:
'Faker<T>.RuleFor<TProperty>(Expression<Func<T, TProperty>>, Func<Faker, T, TProperty>)'
and 'Faker<T>.RuleFor<TProperty>(Expression<Func<T, TProperty>>, TProperty)'
Why can't I assign null to that model?
The following should work:
The reason there's an ambigrous call is because you need to be a bit more specific about what "rule for" method you want to use. eg:
.RuleFor(expr, value)or.RuleFor(expr, Func<T>)etc...Thanks, hope that helps,
Brian Chavez