I have the following class:
public class Script
{
IPrinter _printer;
public Script(IPrinter printer)
{
_printer = printer;
}
public void Print(TextWriter writer)
{
_printer.PrintComment(writer, "lolz");
writer.WriteLine("omg this complicates things";
_printer.PrintSpecial(writer);
if (signoff)
_printer.PrintComment(writer, "kthxbye");
}
}
How would I setup a test to asserts that the printer methods are called in the correct order with the correct parameters?
I could manually create a 'fake' printer and do a state test on writer, but since the context is big (specially since script is also working with the writer) I'd like to avoid it.
I'm using nunit and rhino mocks. Any thoughts on architectural changes or mocking procedures to make this easier to test are appreciated. The real code I'm working with is unfortunately more complex - but this is the gist.