Reputation: 2377
public class ClassUnderTest
{
void Process(Func<string, bool> doSomething)
{
//other code
doSomething("123");
}
}
How do I assert that doSomething is called with parameter 123?
Upvotes: 0
Views: 65
Reputation: 73492
It's as simple as that. Just create a delegate which does the assertion and pass it to the Process
method.
For example:
[Test]
public void SomeTestCase()
{
ClassUnderTest sut = new ClassUnderTest();
Func<string, bool> func = (param)=>
{
Assert.That(param, Is.EqualTo("123"));
return true;//or whatever
};
sut.Process(func);
}
Upvotes: 1
Reputation: 791
You can use for example Rhino Mocks:
someObject.AssertWasCalled(x => x.doSomething("123"));
Upvotes: 0