Here is an example of what I have:
public class ClassToBeTestedTest
{
private Mock<IAService> aService;
private Mock<IAnotherService> anotherService;
private ClassToBeTested testedClass;
[SetUp]
public void setup()
{
aService = new Mock<IAService>();
anotherService = new Mock<IAnotherService>();
testedClass = new ClassToBeTested(aService.Object, anotherService.Object);
}
[Test]
public void ShouldCallAServiceMethodBeforeAnotherService()
{
testedClass.Run();
aService.Verify(x=>x.AMethod(), Times.Once());
anotherService.Verify(x=>x.AnotherMethod(), Times.Once());
}
}
In this example, I just check to see if they were called, there is no sequence ...
Im considering setting a callback in those methods that add some sequence control in a test class ...
edit: I am using moq lib: http://code.google.com/p/moq/
source
share