정확하게 이해했다면 세 가지 지정된 방법 중 하나 이상에서 인터페이스가 한 번 이상 호출되는지 확인하고 싶습니다. 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