I have the following test:
[Test]
public void Load()
{
INestedUnitOfWork unitOfWork = Isolate.Fake.Instance<INestedUnitOfWork>();
IAmazonCredentials credentials = Isolate.Fake.Instance<IAmazonCredentials>();
AmazonCredentialsForm view = Isolate.Fake.Instance<AmazonCredentialsForm>();
WizardPresenter wp = Isolate.Fake.Instance<WizardPresenter>();
Isolate.Swap.NextInstance<WizardPresenter>().With(wp);
AmazonCredentialsFormPresenter presenter = new AmazonCredentialsFormPresenter(unitOfWork, credentials, view);
Isolate.Invoke.Event(() => view.Load += null);
Isolate.Verify.WasCalledWithAnyArguments(() => wp.ConfigureButtons());
Isolate.Verify.WasCalledWithAnyArguments(() => view.NameTextEdit.Focus());
}
The view.Load event is wired up in the constructor of the AmazonCredentialsFormPresenter to a private function:
void mView_Load(object sender, EventArgs e)
{
mWizardPresenter.ConfigureButtons();
mView.NameTextEdit.Focus();
}
The test is failing on the Isolate.Invoke.Event line with a System.NullReferenceException. I've tried a few variations, such as:
Isolate.Invoke.Event(() => view.Load += null, EventArgs.Empty);
and
Isolate.Invoke.Event(() => view.Load += null, this, EventArgs.Empty);
but all give the same result.
What am I missing here?