Hi,
I'm trying to write a test that make sure that I do certain calls to certain objects. The test should fail
(a) If I do not do all calls in my object under test and
(b) If I do more calls in my object under test then I expected
(a) is pretty easy. MockManager.Verify will check for that, right?
so now for (b).
See following code
class ClassA
{
private ClassB b;
private ClassC c;
public ClassA()
{
b = new ClassB();
c = new ClassC();
b.Subscribe(c);
}
}
class ClassB
{
public ClassB()
{
}
public void Subscribe(ClassC c)
{
}
}
class ClassC
{
public ClassC()
{
}
}
[TestFixture]
public class TestFix
{
[Test]
public void Test_Init()
{
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
recorder.DefaultBehavior.CheckArguments();
ClassB b = new ClassB();
ClassC c = new ClassC();
//b.Subscribe(c);
}
ClassA a = new ClassA();
MockManager.Verify();
}
}
In the c'tor of ClassA, I call b.Subscribe(c). My test still passes, even though I did not specify it in my test.
Is there a way to fail a test if let's say any calls are made to b that are not expected?