私が正しく理解していれば、指定された3つの方法のいずれかでインターフェイスが少なくとも1回は呼び出されていることを確認する必要があります。 the quick referenceを見て、私はあなたがRhino Mockでそれを行うことはできないと思います。
直感的に私はあなたが脆いテストを書こうとしていると思います。これはです。悪いことです。これは、テスト対象のクラスの不完全な指定を意味します。私は、テスト中のクラスとテストが既知の振る舞いを持つことができるように、デザインを考えることを強くお勧めします。
しかし、例では便利なので、いつでもこのようにすることができます(ですが、はありません)。
[TestFixture]
public class MyTest {
// The mocked interface
public class MockedInterface implements MyInterface {
int counter = 0;
public method1() { counter++; }
public method2() { counter++; }
public method3() { counter++; }
}
// The actual test, I assume you have the ClassUnderTest
// inject the interface through the constructor and
// the methodToTest calls either of the three methods on
// the interface.
[TestMethod]
public void testCallingAnyOfTheThreeMethods() {
MockedInterface mockery = new MockedInterface();
ClassUnderTest classToTest = new ClassUnderTest(mockery);
classToTest.methodToTest();
Assert.That(mockery.counter, Is.GreaterThan(1));
}
}
(誰かが私のコードをチェックし、私は今、私の頭からこれを書いているし、今では約一年のためのC#のものを書いていない)
私はなぜあなたを知って興味しかしこれをやっている。
私はMendeltがDoメソッドを参照していると思います。 –
あまりにも短い答えに便利なコメントありがとうございます。それを質問に加えました。 – Mendelt