<p>Say I have an interface IFoo which I am mocking. There are 3 methods on this interface. I need to test that the system under test calls at least one of the three methods. I don't care how many times, or with what arguments it does call, but the case where it ignores all the methods and does not touch the IFoo mock is the failure case.</p>

<p>I've been looking through the Expect.Call documentation but can't see an easy way to do it.</p>

<p>Any ideas?</p>

[{'answer_id': 53671, 'author': 'Mendelt', 'author_id': 3320, 'author_profile': 'https://Stackoverflow.com/users/3320', 'pm_score': 1, 'selected': False, 'text': "<p>You can give rhino mocks a lambda to run when a function get's called. This lambda can then increment a counter. Assert the counter > 1 and you're done.</p>\n\n<p>Commented by Don Kirkby:\nI believe Mendelt is referring to the Do method.</p>\n"}, {'answer_id': 58579, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>Not sure this answers your question but I've found that if I need to do anything like that with Rhino (or any similiar framework/library), anything that I didn't know how to do upfront, then I'm better just creating a manual mock. </p>\n\n<p>Creating a class that implements the interface and sets a public boolean field to true if any of the methods is called will be trivially easy, you can give the class a descriptive name which means that (most importantly) the next person viewing the code will immediately understand it.</p>\n"}, {'answer_id': 58623, 'author': 'Spoike', 'author_id': 3713, 'author_profile': 'https://Stackoverflow.com/users/3713', 'pm_score': 0, 'selected': False, 'text': '<p>If I understood you correctly you want to check that the interface is called at least once on any of three specified methods. Looking through <a href="http://www.ayende.com/wiki/GetFile.aspx?File=Rhino+Mocks+3.3+Quick+Reference.pdf" rel="nofollow noreferrer">the quick reference</a> I don\'t think you can do that in Rhino Mocks. </p>\n\n<p>Intuitively I think you\'re trying to write a test that is brittle, which is <strong>a bad thing</strong>. This implies incomplete specification of the class under test. I urge you to think the design through so that the class under test and the test can have a known behavior.</p>\n\n<p>However, to be useful with an example, you could always do it like this (<strong>but don\'t</strong>).</p>\n\n<pre><code>[TestFixture]\npublic class MyTest {\n\n    // The mocked interface\n    public class MockedInterface implements MyInterface {\n       int counter = 0;\n       public method1() { counter++; }\n       public method2() { counter++; }\n       public method3() { counter++; }\n    }\n\n    // The actual test, I assume you have the ClassUnderTest\n    // inject the interface through the constructor and\n    // the methodToTest calls either of the three methods on \n    // the interface.\n    [TestMethod]\n    public void testCallingAnyOfTheThreeMethods() {\n        MockedInterface mockery = new MockedInterface();\n        ClassUnderTest classToTest = new ClassUnderTest(mockery);\n\n        classToTest.methodToTest();\n\n        Assert.That(mockery.counter, Is.GreaterThan(1));\n    }\n}\n</code></pre>\n\n<p><em>(Somebody check my code, I\'ve written this from my head now and haven\'t written a C# stuff for about a year now)</em></p>\n\n<p>I\'m interested to know why you\'re doing this though.</p>\n'}]
['https://Stackoverflow.com/questions/53666', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3024/']