The project that I have just joined uses the command pattern quite extensively for handling calls into the business logic layers of the project.
The business logic layers are built as static handlers calling into providers. The commands then call into these static handlers.
The team want to improve test coverage, and I would like us to move more toward true TDD but the use of static handlers means that there is a hard coded dependency in the commands and there is no way to inject the handlers as dependencies and so it is very difficult to unit test the commands in isolation.
Does anyone have any good suggestions for a strategy for us to move toward a more testable command pattern bearing in mind that there are a lot of commands already in use.
The process method below would be called when execute is called on the command. This would be the method under test. This is a typical example of the usage of static handlers in the command classes.
protected override bool Process()
{
this.user = SecurityHandler.ActivateUser(this.activationGuid);
bool success = this.user != null;
if (!success)
{
this.AddStatusMessage(StatusMessageType.Error, "/Commands/Security/ActivateUserCommand/IncorrectLink", true);
}
return success;
}