using System.Collections.Generic; using System.Linq; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.Properties; using Ringtoets.Integration.Data.StandAlone; using Ringtoets.Integration.Data.StandAlone.SectionResult; using Ringtoets.Integration.Plugin; namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos { [TestFixture] public class StrengthStabilityPointConstructionFailureMechanismSectionResultContextTreeNodeInfoTest { 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(FailureMechanismSectionResultContext)); } [Test] public void Initialized_Always_ExpectedPropertiesSet() { // Assert Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType); Assert.IsNull(info.ChildNodeObjects); Assert.IsNull(info.ForeColor); Assert.IsNull(info.EnsureVisibleOnCreate); 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] public void Text_Always_ReturnsName() { // Setup mocks.ReplayAll(); var mechanism = new StrengthStabilityPointConstructionFailureMechanism(); var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism); // Call var text = info.Text(context); // Assert Assert.AreEqual("Oordeel", text); mocks.VerifyAll(); } [Test] public void Image_Always_ReturnsGenericInputOutputIcon() { // Call var image = info.Image(null); // Assert TestHelper.AssertImagesAreEqual(Resources.GenericInputOutputIcon, image); } [Test] public void ContextMenuStrip_Always_CallsBuilder() { // Setup var gui = mocks.StrictMultiMock(); var treeViewControl = mocks.StrictMock(); var menuBuilderMock = mocks.StrictMock(); gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); gui.Expect(g => g.ProjectOpened += null).IgnoreArguments(); menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.Build()).Return(null); mocks.ReplayAll(); plugin.Gui = gui; // Call info.ContextMenuStrip(null, null, treeViewControl); // Assert mocks.VerifyAll(); } } }