Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionCommentContextTreeNodeInfoTest.cs =================================================================== diff -u -r5ef5e3e186036b4985798236624d86b2801b87d3 -rfc38d18fc6ff1749476da0ea43281d5d80568283 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionCommentContextTreeNodeInfoTest.cs (.../AssessmentSectionCommentContextTreeNodeInfoTest.cs) (revision 5ef5e3e186036b4985798236624d86b2801b87d3) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionCommentContextTreeNodeInfoTest.cs (.../AssessmentSectionCommentContextTreeNodeInfoTest.cs) (revision fc38d18fc6ff1749476da0ea43281d5d80568283) @@ -19,7 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System.Drawing; using System.Linq; using Core.Common.Controls.TreeView; using Core.Common.Gui; @@ -39,26 +38,21 @@ public class AssessmentSectionCommentContextTreeNodeInfoTest { 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(CommentContext)); } - [TearDown] - public void TearDown() - { - plugin.Dispose(); - } - [Test] public void Initialized_Always_ExpectedPropertiesSet() { + // Setup + using (var plugin = new RingtoetsGuiPlugin()) + { + var info = GetInfo(plugin); + // Assert Assert.AreEqual(typeof(CommentContext), info.TagType); Assert.IsNull(info.EnsureVisibleOnCreate); @@ -76,62 +70,88 @@ Assert.IsNull(info.OnDrop); Assert.IsNull(info.ForeColor); } +} [Test] public void Text_Always_ReturnsName() { // Setup var assessmentSectionMock = mocks.StrictMock(); - var context = new CommentContext(assessmentSectionMock); mocks.ReplayAll(); - // Call - var text = info.Text(context); + using (var plugin = new RingtoetsGuiPlugin()) + { + var info = GetInfo(plugin); - // Assert - Assert.AreEqual("Opmerkingen", text); + var context = new CommentContext(assessmentSectionMock); + + // Call + var text = info.Text(context); + + // Assert + Assert.AreEqual("Opmerkingen", text); + + mocks.VerifyAll(); + } } [Test] public void Image_Always_ReturnsSetImage() { // Setup var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); + + using (var plugin = new RingtoetsGuiPlugin()) + { + var info = GetInfo(plugin); var context = new CommentContext(assessmentSectionMock); - mocks.ReplayAll(); + // Call + var image = info.Image(context); - // Call - var image = info.Image(context); + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image); - // Assert - TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image); + mocks.VerifyAll(); + } } [Test] public void ContextMenuStrip_Always_CallsBuilder() { // Setup - var mocks = new MockRepository(); - var gui = mocks.StrictMultiMock(); - var treeViewControl = mocks.StrictMock(); - var menuBuilderMock = mocks.StrictMock(); + using (var plugin = new RingtoetsGuiPlugin()) + { + var gui = mocks.StrictMock(); + var treeViewControl = mocks.StrictMock(); + var menuBuilderMock = mocks.StrictMock(); - gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); - menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock); - menuBuilderMock.Expect(mb => mb.Build()).Return(null); + menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); - mocks.ReplayAll(); + var info = GetInfo(plugin); - plugin.Gui = gui; + mocks.ReplayAll(); - // Call - info.ContextMenuStrip(null, null, treeViewControl); + plugin.Gui = gui; + // Call + info.ContextMenuStrip(null, null, treeViewControl); + } + // Assert mocks.VerifyAll(); } + + private TreeNodeInfo GetInfo(Core.Common.Gui.Plugin.GuiPlugin gui) + { + return gui.GetTreeNodeInfos().First(tni => tni.TagType == typeof(CommentContext)); + } } }