using System.Drawing; using System.Linq; using System.Windows.Forms; 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.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Plugin; using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; namespace Ringtoets.Piping.Forms.Test.TreeNodeInfos { [TestFixture] public class EmptyPipingOutputTreeNodeInfoTest { private MockRepository mocks; private PipingGuiPlugin plugin; private TreeNodeInfo info; [SetUp] public void SetUp() { mocks = new MockRepository(); plugin = new PipingGuiPlugin(); info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(EmptyPipingOutput)); } [Test] public void Initialized_Always_ExpectedPropertiesSet() { // Assert Assert.AreEqual(typeof(EmptyPipingOutput), info.TagType); 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] public void Text_Always_ReturnsFromResource() { // Call var text = info.Text(null); // Assert Assert.AreEqual(PipingFormsResources.PipingOutput_DisplayName, text); } [Test] public void Image_Always_ReturnsPlaceHolderIcon() { // Call var image = info.Image(null); // Assert TestHelper.AssertImagesAreEqual(PipingFormsResources.PipingOutputIcon, image); } [Test] public void ForeColor_Always_ReturnsGrayText() { // Call var textColor = info.ForeColor(null); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), textColor); } [Test] public void GetContextMenu_Always_CallsContextMenuBuilderMethods() { // Setup var gui = mocks.StrictMock(); var menuBuilderMock = mocks.StrictMock(); var nodeMock = mocks.StrictMock(); menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.Build()).Return(null); gui.Expect(cmp => cmp.Get(nodeMock, info)).Return(menuBuilderMock); mocks.ReplayAll(); plugin.Gui = gui; // Call info.ContextMenuStrip(null, nodeMock, info); // Assert mocks.VerifyAll(); } } }