Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ReferenceLineContextTreeNodeInfoTest.cs =================================================================== diff -u -ra9aafffab97152303562110b1d789bacb465ce24 -rfc38d18fc6ff1749476da0ea43281d5d80568283 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ReferenceLineContextTreeNodeInfoTest.cs (.../ReferenceLineContextTreeNodeInfoTest.cs) (revision a9aafffab97152303562110b1d789bacb465ce24) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ReferenceLineContextTreeNodeInfoTest.cs (.../ReferenceLineContextTreeNodeInfoTest.cs) (revision fc38d18fc6ff1749476da0ea43281d5d80568283) @@ -24,41 +24,37 @@ public class ReferenceLineContextTreeNodeInfoTest { private MockRepository mocks; - private RingtoetsGuiPlugin plugin; - private TreeNodeInfo info; [SetUp] public void SetUp() { mocks = new MockRepository(); - plugin = new RingtoetsGuiPlugin(); - info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ReferenceLineContext)); } - [TearDown] - public void TearDown() - { - plugin.Dispose(); - } - [Test] public void Initialized_Always_ExpectedPropertiesSet() { - // Assert - Assert.AreEqual(typeof(ReferenceLineContext), info.TagType); - Assert.IsNull(info.EnsureVisibleOnCreate); - Assert.IsNull(info.ChildNodeObjects); - Assert.IsNull(info.CanRename); - Assert.IsNull(info.OnNodeRenamed); - Assert.IsNull(info.CanRemove); - Assert.IsNull(info.OnNodeRemoved); - Assert.IsNull(info.CanCheck); - Assert.IsNull(info.IsChecked); - Assert.IsNull(info.OnNodeChecked); - Assert.IsNull(info.CanDrag); - Assert.IsNull(info.CanDrop); - Assert.IsNull(info.CanInsert); - Assert.IsNull(info.OnDrop); + // Setup + using (var plugin = new RingtoetsGuiPlugin()) + { + var info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(ReferenceLineContext), info.TagType); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ChildNodeObjects); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.OnNodeRenamed); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.IsChecked); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.CanDrag); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.OnDrop); + } } [Test] @@ -70,12 +66,16 @@ var referenceLineContext = new ReferenceLineContext(assessmentSection); - // Call - var text = info.Text(referenceLineContext); + using (var plugin = new RingtoetsGuiPlugin()) + { + var info = GetInfo(plugin); - // Assert - Assert.AreEqual("Referentielijn", text); + // Call + var text = info.Text(referenceLineContext); + // Assert + Assert.AreEqual("Referentielijn", text); + } mocks.VerifyAll(); } @@ -88,12 +88,16 @@ var referenceLineContext = new ReferenceLineContext(assessmentSection); - // Call - var image = info.Image(referenceLineContext); + using (var plugin = new RingtoetsGuiPlugin()) + { + var info = GetInfo(plugin); - // Assert - TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.ReferenceLineIcon, image); + // Call + var image = info.Image(referenceLineContext); + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.ReferenceLineIcon, image); + } mocks.VerifyAll(); } @@ -105,16 +109,22 @@ var treeViewControlMock = mocks.StrictMock(); var menuBuilderMock = mocks.StrictMock(); gui.Expect(g => g.Get(null, treeViewControlMock)).Return(menuBuilderMock); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.Build()).Return(null); mocks.ReplayAll(); - plugin.Gui = gui; + using (var plugin = new RingtoetsGuiPlugin()) + { + var info = GetInfo(plugin); - // Call - info.ContextMenuStrip(null, null, treeViewControlMock); + plugin.Gui = gui; + // Call + info.ContextMenuStrip(null, null, treeViewControlMock); + } // Assert mocks.VerifyAll(); } @@ -128,11 +138,16 @@ var referenceLineContext = new ReferenceLineContext(assessmentSection); - // Call - Color color = info.ForeColor(referenceLineContext); + using (var plugin = new RingtoetsGuiPlugin()) + { + var info = GetInfo(plugin); - // Assert - Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); + // Call + Color color = info.ForeColor(referenceLineContext); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); + } mocks.VerifyAll(); } @@ -146,12 +161,22 @@ var referenceLineContext = new ReferenceLineContext(assessmentSection); - // Call - Color color = info.ForeColor(referenceLineContext); + using (var plugin = new RingtoetsGuiPlugin()) + { + var info = GetInfo(plugin); - // Assert - Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); + // Call + Color color = info.ForeColor(referenceLineContext); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); + } mocks.VerifyAll(); } + + private TreeNodeInfo GetInfo(RingtoetsGuiPlugin guiPlugin) + { + return guiPlugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ReferenceLineContext)); + } } } \ No newline at end of file