这是我需要进行单元测试的方法:
void Do(IEnumerable<string> items, TextWriter tw){
foreach(var item in items) { tw.WriteLine(item); }
}
如何配置一个模拟TextWriter
来验证某些参数是否以WriteLine
特定顺序传递给相同的方法()?
[Test]
public void Test(){
var mock = new Mock<TextWriter>();
mock.Setup( ??? ); //check that WriteLine is called 3 times,
//with arguments "aa","bb","cc", in that order.
Do(new[]{"aa", "bb", "cc"}, mock);
mock.Verify();
}