I am writing unit for a class which looks like following using nunit and Rhino mock.
Class MyClass
{
private void M()
{
N("Hi");
}
private void N(string text)
{
........ do something
}
}
For the unit test for method M I want to check if method N was called with argument “Hi”. How do I do it?
It seems to me that from the point of view of testing, you’re delving into the implementation details of your object. Can’t you perform your tests by checking the ultimate result of your method call ? That is, presumably these method calls have some effect. So rather than checking the arguments being passed, you should be checking the final result.
That way you can change your underlying code at a later date, and your unit tests will confirm that the ultimate result is the same, independent of your implementation.