Expect multiple calls to method
How can I tell Moq to expect multiple calls so I can still use the
MockRepository to VerifyAll, as below?
[TestFixture]
public class TestClass
{
[SetUp]
public void SetUp()
{
_mockRepository = new MockRepository(MockBehavior.Strict);
_mockThing = _mockRepository.Create<IThing>();
_sut = new Sut(_mockThing.Object);
}
[TearDown]
public void TearDown()
{
_mockRepository.VerifyAll();
}
private Mock<IThing> _mockThing;
private MockRepository _mockRepository;
[Test]
public void TestManyCalls(Cell cell)
{
_mockThing.SetUp(x => x.DoSomething()).Return(new DoneStatus());
}
}
I know you can do this at verify time, but then I would have to verify
everything independently. Is there a to tell it what to expect, rather
than verifying it after the event?
Somthing similar to:
_mockThing.SetUp(x => x.DoSomething()).Return(new DoneStatus()).Times(20);
No comments:
Post a Comment