What you should be doing is simply making sure that f.Bar calls the delegate that is passed to it -- which is really what is happening. Something like this won't need Rhino.Mocks. You could do:
var methodCalled = false; var foo = new Foo(); f.Bar(() => methodCalled = true); Assert.IsTrue(methodCalled); If bar never calls the delegate passed to it, methodCalled will still be false and your test will fail. --- Patrick Steele http://weblogs.asp.net/psteele On Sat, Feb 4, 2012 at 1:19 PM, Dave <[email protected]> wrote: > How does one go about testing that a delegate was passed to a method? I > have a class with a method: > > class Worker { > > public void MainLoop() { > } > } > > And another class > > class Foo { > > public void Bar( Action methodToRunInLoop) { > ... > } > } > > and some code that does this > > Worker w = new Worker(); > Foo f = new Foo(); > f.Bar(w.MainLoop); > > What I want to do is to verify that "f.Bar(w.MainLoop);" was called. > > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Rhino.Mocks" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rhinomocks/-/GdRWRi8e948J. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rhinomocks?hl=en. -- You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.
