6
IEnumerable的我有與需要一個IEnumerable作爲參數的添加方法的存儲庫:驗證方法被調用用含有「x」的元件與起訂量
public void Add<T>(T item) where T : class, new(){}
在單元測試我想要驗證,該方法是叫與包含正好元件相同量爲單位測試的另一個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())));
}
結果一個IEnumerable:
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.
我在做什麼錯?