I am writing client-side components in a provided framework, and need to be able to unit test my components. The components are written using MVP (Model-View-Presenter) pattern, I want to use PEX to automatically generate unit tests for my presenters.
The following is the code of a presenter.
public partial class CompetitorPresenter : PresenterBase
{
private readonly ICompetitorView _view;
public IGlobalDataAccess GlobalDataAccess;
public IGlobalUI Globals;
public SystemClient Client;
public bool DeleteRecord()
{
if (_view.CompetitorName != "Daniel")
return false;
if (Client.SystemName != "Ruby")
return false;
return true;
}
}
The problem I am having is that the object SystemClient
is provided by the framework, and I cannot use a factory class to create an instance of SystemClient
. Therefore when I run PEX to automatically generate unit tests, I have to tell PEX to ignore SystemClient
, the result of this is that the method DeleteRecord
is not fully covered as the line Client.SystemName != "Ruby"
is not tested.
Since I have the mock object MSystemClient
(created using moles), I am wondering if somewhere in the configuration I could tell PEX to use MSystemClient
, and let PEX to automatically generate test cases to fully cover this method.