I have a class Athat calls a method on an interface B, passing one of its own methods to it as a kind of continuation, which Bshould be called when it has a result. In practice, this code works fine, but I can't figure out how to test it with Moq - when I try to do the obvious thing, it creates System.ArgumentException : method argument length mismatch. At first I thought that it could be my code, but it does not work the same way as in the following case:
public class A
{
readonly B myB;
public A (B b)
{
myB = b;
}
public void HandleC (C c)
{
}
public void DoFindC ()
{
myB.FindC (HandleC);
}
}
public interface B
{
void FindC (Action<C> handleC);
}
public interface C
{
}
[TestFixture()]
public class ATest
{
[Test()]
public void TestDoFindC ()
{
Mock<B> bMock = new Mock<B> ();
A a = new A(bMock.Object);
a.DoFindC();
bMock.Verify(b => b.FindC(a.HandleC));
}
}
I guess there are some backstage magic with delegates that I don't understand yet, being relatively new to C #, but what's the right way to check this out?
:. Mono 2.6.7 MacOS 10.6.5 .NET 3.5.
: , Mono; https://bugzilla.novell.com/show_bug.cgi?id=656918.