📜  moq 设置延迟返回 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:06.560000             🧑  作者: Mango

代码示例1
Mock mockFoo = new Mock();
mockFoo.Setup(f => f.Bar())
       .Callback(() => Thread.Sleep(1000))
       .Returns("test");

string result = mockFoo.Object.Bar(); // will take 1 second to return

Assert.AreEqual("test", result);