Question: i got a class that gets by argument a delegate.
This class invokes that delegate, and i want to unit test it with Moq.
how do i verify that this method was called ?

example class :

```
public delegate void Foo(int number);

public class A
{
   int a = 5;

   public A(Foo myFoo)
   {
      myFoo(a);
   }
}

```

and I want to check that Foo was called.
Thank you.

Answer: 
You can do something like that:

```
 public interface IWithFOOMethod
 {
     void FooAlikeMethod(int number);
 }

 Mock<IWithFOOMethod> myMock = new Mock<IWithFOOMethod>();

 A a = new A(myMock.Object.FooAlikeMethod);

 myMock.Verify(call => call.Foo(It.IsAny<int>()), Times.Once())

```
Since Moq doesn't support mocking delegates, I'll usually handle this with something like:

```
var list = new List<int> ();
var del = i => list.Add (i);
var a = new A(del);
list.ShouldContainOnly (new[] { 5 });

```

where the delegate provided performs some simple, verifiable action.