Метод проверки был вызван с IEnumerable, содержащим элементы «x» с помощью Moq

У меня есть репозиторий с методом Add, который принимает IEnumerable в качестве параметра:

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.

Что я делаю не так?

7
задан Andrew 2 June 2011 в 13:09
поделиться