Open jcotton42 opened 1 year ago
I have the same issue, RuleFor
doesn't have any effect because my classes only contain properties that are get-only, only initialized by the constructor:
var products = new AutoFaker<Product>()
.RuleFor(p => p.ProductId, f => f.Random.Int(1))
.Generate(3);
public class Product
{
public Product(
long productId,
string productName)
{
ProductId = productId;
ProductName = productName;
}
public long ProductId { get; }
public string ProductName { get; }
}
It would be nice if AutoBogus could initialize the object automatically using constructor parameters if necessary.
It still can't do that. Any news?
I was attempting to use AutoBogus.Moq to generate some fake data interfaces. Unfortunately the interfaces in question have get-only properties, which AutoBogus.Moq doesn't seem to support.
Is this reasonably doable? Or would the best solution for situations like mine be to create fakes manually using Moq and regular Bogus?
At the very least some sort of exception seems appropriate, the above code doesn't throw anything, despite the
RuleFor
s have no effect when used on anIGet
.