Skip to content

Instantly share code, notes, and snippets.

@jhgbrt
Created July 19, 2012 14:25
Show Gist options
  • Save jhgbrt/3144300 to your computer and use it in GitHub Desktop.
Save jhgbrt/3144300 to your computer and use it in GitHub Desktop.
[Test]
public void EnsureDependencyIsCalledWithCorrectArguments()
{
var dependency = MockRepository.GenerateMock<IDependency>();
dependency.Expect(x => x.DoSomething(null, 0))
.IgnoreArguments().Return(7).Repeat.Once();
dependency.Expect(x => x.DoSomething(null, 0))
.IgnoreArguments().Return(3).Repeat.Once();
var systemUnderTest = new SystemUnderTest(dependency);
var returned = systemUnderTest.MethodUnderTest("MyData", 1234);
Assert.AreEqual(10, returned);
dependency.AssertWasCalled(d =>
d.DoSomething(Arg<SomeComplexType>.Matches(t => t.stringData == "Sending MyData"),
Arg.Is(1111))
);
dependency.AssertWasCalled(d =>
d.DoSomething(Arg<SomeComplexType>.Matches(t => t.stringData == "Sending 1234"),
Arg.Is(2222))
);
}
@joaoportela
Copy link

Thank you for this. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment