Hi!,
I'm having an issue with writing a Unit Test for a Rule that's setted for checking the Length of a List of custom objects. The Rule is a follows:
Thanks!
I'm having an issue with writing a Unit Test for a Rule that's setted for checking the Length of a List of custom objects. The Rule is a follows:
public class OrderValidator : AbstractValidator<Order>
{
public OrderValidator()
{
RuleFor(order => order.OrderItems.Count).LessThanOrEqualTo(10);
}
}
And the Unit Test on the Rule is: [TestMethod]
public void Should_have_error_when_OrderItems_count_greater_than_10()
{
var order = A.Fake<Order>();
order.OrderItems = new List<OrderItem>(new OrderItem[12]);
orderValidator.ShouldHaveValidationErrorFor(o => o.OrderItems.Count, order);
}
It throws an exception that the lambda expression must be writeable. Is there a workaround for this or I'm doing something wrong?.Thanks!