Skip to content

Instantly share code, notes, and snippets.

@dtchepak
Created September 30, 2010 07:07
Show Gist options
  • Save dtchepak/604153 to your computer and use it in GitHub Desktop.
Save dtchepak/604153 to your computer and use it in GitHub Desktop.
public interface IFoo { void MyMethod(Action<int[]> callback); }
[Test]
public void TestCallback()
{
var sub = Substitute.For<IFoo>();
var callback = Substitute.For<Action<int[]>>();
var data = new[] { 1, 2, 3 };
sub.When(x => x.MyMethod(callback))
.Do(x => callback(data));
sub.MyMethod(callback);
callback.Received()(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment