Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs =================================================================== diff -u -r50b203a8d5c805fc548fb6b92c70a847190da6a5 -r2227f1d3a31b15a6d05c5385898d5da4b79dcdea --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 50b203a8d5c805fc548fb6b92c70a847190da6a5) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 2227f1d3a31b15a6d05c5385898d5da4b79dcdea) @@ -30,6 +30,7 @@ using Core.Common.Gui; using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Forms.MainWindow; +using Core.Common.Gui.Forms.ViewHost; using Core.Common.Gui.Plugin; using Core.Common.Gui.Settings; using Core.Common.TestUtil; @@ -452,5 +453,47 @@ Assert.AreEqual(1, importers.Count(i => i is FailureMechanismSectionsImporter)); } } + + [Test] + public void Activate_WithoutGui_ThrowsInvalidOperationException() + { + // Setup + using (var plugin = new RingtoetsPlugin()) + { + // Call + TestDelegate test = () => plugin.Activate(); + + // Assert + Assert.Throws(test); + } + } + + [Test] + public void Activate_WithGui_DoesNotThrowException() + { + // Setup + var mockRepository = new MockRepository(); + var mainWindowMock = mockRepository.StrictMock(); + var documentViewControllerMock = mockRepository.StrictMock(); + var guiMock = mockRepository.StrictMock(); + guiMock.Expect(g => g.MainWindow).Return(mainWindowMock); + guiMock.Expect(g => g.DocumentViewController).Return(documentViewControllerMock); + guiMock.Expect(g => g.ProjectOpened += null).IgnoreArguments(); + guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + mockRepository.ReplayAll(); + + using (var plugin = new RingtoetsPlugin()) + { + plugin.Gui = guiMock; + + // Call + TestDelegate test = () => plugin.Activate(); + + // Assert + Assert.DoesNotThrow(test); + } + + mockRepository.VerifyAll(); + } } } \ No newline at end of file