Given this class:
public class OrderService
{
public OrderService(IOrderLogger log)
{
this.log = log;
}
private readonly IOrderLogger log;
public void PurgeOrder(Order order)
{
...
var action = new LogAction("foo","bar");
log.Action(action);
}
}
And this test:
[Fact]
public void PurgeOrder_should_log_action()
{
var order = new Order();
var logger = MockRepository.GenerateStub<IOrderLogger>();
var service = new OrderService(logger);
service.PurgeOrder(order);
logger.AssertWasCalled(x => x.Action(????));
}
Obviously the test is wrong. How can I assert the OrderLogger.Action(...) was actually called in this scenario? If the LogAction is instantiated inside the PurgeOrder method, I don't see how it's possible. Any suggestions?