IEnumerableをパラメーターとして受け取るAddメソッドを持つリポジトリがあります。
public void Add<T>(T item) where T : class, new(){}
単体テストで、このメソッドが別のIEnumerableとまったく同じ量の要素を含むIEnumerableで呼び出されていることを確認したいと思います。
[Test]
public void InvoicesAreGeneratedForAllStudents()
{
var students = StudentStub.GetStudents();
session.Setup(x => x.All<Student>()).Returns(students.AsQueryable());
service.GenerateInvoices(Payments.Jaar, DateTime.Now);
session.Verify(x => x.Add(It.Is<IEnumerable<Invoice>>(
invoices => invoices.Count() == students.Count())));
}
単体テストの結果:
Moq.MockException :
Expected invocation on the mock at least once, but was never performed:
x => x.Add<Invoice>(It.Is<IEnumerable`1>(i => i.Count<Invoice>() == 10))
No setups configured.
私は何が間違っているのですか?