我有一个继承自IEnumerable
. 我需要这个类中的一个方法,它将导航到列表中的下一个项目,并相应地循环回到开头。
一些示例代码如下:
public class Enrolments : IEnumerable<IEnrolment>
{
public IEnrolment GetNextEnrolment()
{
}
}
我需要以下测试才能有效
IEnrolment enrolment1 = new Enrolment();
IEnrolment enrolment2 = new Enrolment();
Enrolments enrolments = new Enrolments {enrolment1, enrolment2};
IEnrolment current;
Assert.That(current, Is.EqualTo(enrolment1));
current = enrolments.GetNextEnrolment();
Assert.That(current, Is.EqualTo(enrolment2));
current = enrolments.GetNextEnrolment();
Assert.That(current, Is.EqualTo(enrolment1));
current = enrolments.GetNextEnrolment();
Assert.That(current, Is.EqualTo(enrolment2));