I have been using Moq for my mocking needs the last years, but after looking at FakeItEasy i wanted to give it a try.
I often want to test that a method have been called with the correct parameters, but i found no satisfactory way to do this with FakeItEasy.
I have the following code to test:
public class WizardStateEngine : IWizardStateEngine
{
private readonly IWorkflowInvoker _workflowInvoker;
private List<CustomBookmark> _history;
public WizardStateEngine(IWorkflowInvoker workflowInvoker)
{
_workflowInvoker = workflowInvoker;
}
public void Initialize(List<CustomBookmark> history)
{
_history = history;
}
public WizardStateContext Execute(Command command, WizardStateContext stateContext, CustomBookmark step)
{
Activity workflow = new MyActivity();
var input = new Dictionary<string, object>();
input["Action"] = command;
input["Context"] = stateContext;
input["BookmarkHistory"] = _history;
var output = _workflowInvoker.Invoke(workflow, input);
_history = output["BookmarkHistory"] as List<CustomBookmark>;
return output["Context"] as WizardStateContext;
}
public List<CustomBookmark> GetBookmarkHistory()
{
return _history;
}
}
I want to write some tests that verifies the input to _workflowInvoker.Invoke(). My TestInitialize method sets up the needed resources and save the input dictionary to _workflowInvoker.Invoke() as a local field _wfInput.
[TestInitialize]
public void TestInitialize()
{
_wizardStateContext = new WizardStateContext();
_workflowInvoker = A.Fake<IWorkflowInvoker>();
_wizardStateEngine = new WizardStateEngine(_workflowInvoker);
_outputContext = new WizardStat