Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingSoilProfileCollectionTreeNodeInfoTest.cs =================================================================== diff -u -r10779bb6a6db2d00f4627b2bc190e7e35e1fee3e -r2ee142712e588101a958207e041c3e9342e5a7fa --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingSoilProfileCollectionTreeNodeInfoTest.cs (.../PipingSoilProfileCollectionTreeNodeInfoTest.cs) (revision 10779bb6a6db2d00f4627b2bc190e7e35e1fee3e) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingSoilProfileCollectionTreeNodeInfoTest.cs (.../PipingSoilProfileCollectionTreeNodeInfoTest.cs) (revision 2ee142712e588101a958207e041c3e9342e5a7fa) @@ -1,4 +1,25 @@ -using System.Collections.Generic; +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Collections.Generic; using System.Drawing; using System.Linq; using Core.Common.Controls.TreeView; @@ -7,7 +28,9 @@ using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.Data; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Plugin; using Ringtoets.Piping.Primitives; @@ -26,14 +49,14 @@ { mocks = new MockRepository(); plugin = new PipingGuiPlugin(); - info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(IEnumerable)); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StochasticSoilModelContext)); } [Test] public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(IEnumerable), info.TagType); + Assert.AreEqual(typeof(StochasticSoilModelContext), info.TagType); Assert.IsNull(info.EnsureVisibleOnCreate); Assert.IsNull(info.CanRename); Assert.IsNull(info.OnNodeRenamed); @@ -52,12 +75,13 @@ public void Text_Always_ReturnsTextFromResource() { // Setup - var pipingSoilProfiles = mocks.StrictMock>(); - + var failureMechanismMock = mocks.StrictMock(); + var assessmentSectionMock = mocks.StrictMock(); + var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock, assessmentSectionMock); mocks.ReplayAll(); // Call - var text = info.Text(pipingSoilProfiles); + var text = info.Text(stochasticSoilModelContextMock); // Assert Assert.AreEqual(Resources.PipingSoilProfilesCollection_DisplayName, text); @@ -69,12 +93,13 @@ public void Image_Always_ReturnsSetImage() { // Setup - var pipingSoilProfiles = mocks.StrictMock>(); - + var failureMechanismMock = mocks.StrictMock(); + var assessmentSectionMock = mocks.StrictMock(); + var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock, assessmentSectionMock); mocks.ReplayAll(); // Call - var image = info.Image(pipingSoilProfiles); + var image = info.Image(stochasticSoilModelContextMock); // Assert TestHelper.AssertImagesAreEqual(Resources.FolderIcon, image); @@ -86,14 +111,13 @@ public void ForeColor_CollectionWithoutSoilProfiles_ReturnsGrayText() { // Setup - var pipingSoilProfiles = mocks.StrictMock>(); - - pipingSoilProfiles.Expect(collection => collection.GetEnumerator()); - + var failureMechanismMock = mocks.StrictMock(); + var assessmentSectionMock = mocks.StrictMock(); + var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock, assessmentSectionMock); mocks.ReplayAll(); // Call - var foreColor = info.ForeColor(pipingSoilProfiles); + var foreColor = info.ForeColor(stochasticSoilModelContextMock); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), foreColor); @@ -105,14 +129,14 @@ public void ForeColor_CollectionWithSoilProfiles_ReturnsControlText() { // Setup - IEnumerable pipingSoilProfiles = new[] - { - new PipingSoilProfile("", 0, new List { new PipingSoilLayer(10) }, 0), - new PipingSoilProfile("", 0, new List { new PipingSoilLayer(10) }, 0) - }; + var failureMechanismMock = mocks.StrictMock(); + var assessmentSectionMock = mocks.StrictMock(); + var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock, assessmentSectionMock); + failureMechanismMock.StochasticSoilModels.Add(new StochasticSoilModel(0, "Name", "Name")); + mocks.ReplayAll(); // Call - var foreColor = info.ForeColor(pipingSoilProfiles); + var foreColor = info.ForeColor(stochasticSoilModelContextMock); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), foreColor); @@ -124,21 +148,43 @@ public void ChildNodeObjects_Always_ReturnsChildsOnData() { // Setup - var pipingSoilProfile1 = new PipingSoilProfile("", 0, new List { new PipingSoilLayer(10) }, 0); - var pipingSoilProfile2 = new PipingSoilProfile("", 0, new List { new PipingSoilLayer(10) }, 0); - IEnumerable pipingSoilProfiles = new[] + var pipingSoilProfile1 = new PipingSoilProfile("", 0, new List { - pipingSoilProfile1, - pipingSoilProfile2 + new PipingSoilLayer(10) + }, 0); + var pipingSoilProfile2 = new PipingSoilProfile("", 0, new List + { + new PipingSoilLayer(10) + }, 0); + var stochasticSoilProfile1 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 1) + { + SoilProfile = pipingSoilProfile1 }; + var stochasticSoilProfile2 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 1) + { + SoilProfile = pipingSoilProfile2 + }; + var stochasticSoilModel = new StochasticSoilModel(0, "Name", "Name"); + stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile1); + stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile2); + + var failureMechanismMock = mocks.StrictMock(); + var assessmentSectionMock = mocks.StrictMock(); + var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock, assessmentSectionMock); + failureMechanismMock.StochasticSoilModels.Add(stochasticSoilModel); + mocks.ReplayAll(); // Call - var objects = info.ChildNodeObjects(pipingSoilProfiles); + var objects = info.ChildNodeObjects(stochasticSoilModelContextMock); // Assert - CollectionAssert.AreEqual(new[] { pipingSoilProfile1, pipingSoilProfile2 }, objects); + CollectionAssert.AreEqual(new[] + { + pipingSoilProfile1, + pipingSoilProfile2 + }, objects); mocks.VerifyAll(); }