Index: Core/Common/test/Core.Common.Gui.TestUtil/PluginTestHelper.cs =================================================================== diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -rdc682a1792664507e869ee5ecda02a9cff5426ea --- Core/Common/test/Core.Common.Gui.TestUtil/PluginTestHelper.cs (.../PluginTestHelper.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639) +++ Core/Common/test/Core.Common.Gui.TestUtil/PluginTestHelper.cs (.../PluginTestHelper.cs) (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -45,12 +45,13 @@ /// . public static PropertyInfo AssertPropertyInfoDefined(IEnumerable propertyInfos, Type dataObjectType, Type propertyObjectType) { - Assert.NotNull(propertyInfos); + Assert.NotNull(propertyInfos, "The given collection of propertyInfos was undefined."); var propertyInfo = propertyInfos.FirstOrDefault( tni => tni.DataType == dataObjectType && tni.PropertyObjectType == propertyObjectType); - Assert.NotNull(propertyInfo); + Assert.NotNull(propertyInfo, $"The property info object was not found for the given dataType ({dataObjectType}) " + + $"and propertyObjectType ({propertyObjectType})."); return propertyInfo; } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/StochasticSoilModelCollectionContext.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/StochasticSoilModelCollectionContext.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/StochasticSoilModelCollectionContext.cs (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -0,0 +1,71 @@ +// 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; +using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.Forms.PresentationObjects +{ + /// + /// The presentation object for . + /// + public class StochasticSoilModelCollectionContext : ObservableWrappedObjectContextBase + { + /// + /// Creates a new instance of . + /// + /// The stochastic soil models to wrap. + /// The failure mechanism. + /// The assessment section. + /// Thrown when any input argument is null. + public StochasticSoilModelCollectionContext(StochasticSoilModelCollection wrappedStochasticSoilModels, + PipingFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + : base(wrappedStochasticSoilModels) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + FailureMechanism = failureMechanism; + AssessmentSection = assessmentSection; + } + + /// + /// Gets the failure mechanism which the context belongs to. + /// + public PipingFailureMechanism FailureMechanism { get; private set; } + + /// + /// Gets the assessment section which the context belongs to. + /// + public IAssessmentSection AssessmentSection { get; private set; } + } +} \ No newline at end of file Fisheye: Tag dc682a1792664507e869ee5ecda02a9cff5426ea refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/StochasticSoilModelsContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r18259e66145f5da6ade4866bee22627fc92b3d71 -rdc682a1792664507e869ee5ecda02a9cff5426ea --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 18259e66145f5da6ade4866bee22627fc92b3d71) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -1484,6 +1484,24 @@ } /// + /// Looks up a localized string similar to De laatst bekende bestandslocatie.. + /// + public static string StochasticSoilModelCollection_LastKnownFilePath_Description { + get { + return ResourceManager.GetString("StochasticSoilModelCollection_LastKnownFilePath_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bestandslocatie. + /// + public static string StochasticSoilModelCollection_LastKnownFilePath_DisplayName { + get { + return ResourceManager.GetString("StochasticSoilModelCollection_LastKnownFilePath_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// public static System.Drawing.Bitmap StochasticSoilModelIcon { Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx =================================================================== diff -u -ra18b7dcb5ed74f0d8ffc9a4d284d98b25816b9b8 -rdc682a1792664507e869ee5ecda02a9cff5426ea --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision a18b7dcb5ed74f0d8ffc9a4d284d98b25816b9b8) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -619,4 +619,10 @@ Gewicht van de deklaag [kN/m²] + + De laatst bekende bestandslocatie. + + + Bestandslocatie + \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/StochasticSoilModelCollectionProperties.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/StochasticSoilModelCollectionProperties.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/StochasticSoilModelCollectionProperties.cs (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -0,0 +1,63 @@ +// 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; +using Core.Common.Gui.PropertyBag; +using Core.Common.Utils.Attributes; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Forms.Properties; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Piping.Forms.PropertyClasses +{ + /// + /// ViewModel of for properties panel. + /// + public class StochasticSoilModelCollectionProperties : ObjectProperties + { + /// + /// Creates a new instance of . + /// + /// The collection for which the properties are shown. + /// Thrown when + /// is null. + public StochasticSoilModelCollectionProperties(StochasticSoilModelCollection collection) + { + if (collection == null) + { + throw new ArgumentNullException(nameof(collection)); + } + data = collection; + } + + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_General")] + [ResourcesDisplayName(typeof(Resources), "StochasticSoilModelCollection_LastKnownFilePath_DisplayName")] + [ResourcesDescription(typeof(Resources), "StochasticSoilModelCollection_LastKnownFilePath_Description")] + public string LastKnownFilePath + { + get + { + return data.LastKnownFilePath; + } + } + + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/StochasticSoilModelProperties.cs =================================================================== diff -u -rc43715cf3e6dce0c427b10c4852d5ae54e6d668d -rdc682a1792664507e869ee5ecda02a9cff5426ea --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/StochasticSoilModelProperties.cs (.../StochasticSoilModelProperties.cs) (revision c43715cf3e6dce0c427b10c4852d5ae54e6d668d) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/StochasticSoilModelProperties.cs (.../StochasticSoilModelProperties.cs) (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -28,7 +28,6 @@ using Core.Common.Utils.Attributes; using Ringtoets.Piping.Data; using Ringtoets.Piping.Forms.Properties; -using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.Piping.Forms.PropertyClasses Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj =================================================================== diff -u -r849754a9c56fc8ad4e2733f9ca04de7c01cbac3f -rdc682a1792664507e869ee5ecda02a9cff5426ea --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision 849754a9c56fc8ad4e2733f9ca04de7c01cbac3f) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -64,7 +64,7 @@ - + True @@ -74,6 +74,7 @@ + Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -r6ddd27897f8c0d4b1e3c4b720e06df9dd855aaf8 -rdc682a1792664507e869ee5ecda02a9cff5426ea --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 6ddd27897f8c0d4b1e3c4b720e06df9dd855aaf8) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -73,6 +73,10 @@ yield return new PropertyInfo(); yield return new PropertyInfo(); yield return new PropertyInfo(); + yield return new PropertyInfo + { + CreateInstance = context => new StochasticSoilModelCollectionProperties(context.WrappedData) + }; yield return new PropertyInfo(); yield return new PropertyInfo(); } @@ -91,7 +95,7 @@ filePath) }; - yield return new ImportInfo + yield return new ImportInfo { Name = PipingFormsResources.StochasticSoilModelCollection_DisplayName, Category = RingtoetsCommonFormsResources.Ringtoets_Category, @@ -225,7 +229,7 @@ OnNodeRemoved = OnSurfaceLineRemoved }; - yield return new TreeNodeInfo + yield return new TreeNodeInfo { Text = stochasticSoilModelContext => PipingFormsResources.StochasticSoilModelCollection_DisplayName, Image = stochasticSoilModelContext => RingtoetsCommonFormsResources.GeneralFolderIcon, @@ -501,12 +505,12 @@ private bool CanRemoveStochasticSoilModel(StochasticSoilModel nodeData, object parentData) { - return parentData is StochasticSoilModelsContext; + return parentData is StochasticSoilModelCollectionContext; } private void OnStochasticSoilModelRemoved(StochasticSoilModel nodeData, object parentData) { - var context = (StochasticSoilModelsContext) parentData; + var context = (StochasticSoilModelCollectionContext) parentData; IObservable[] changedObservables = PipingDataSynchronizationService.RemoveStochasticSoilModel(context.FailureMechanism, nodeData).ToArray(); @@ -597,7 +601,7 @@ { new FailureMechanismSectionsContext(failureMechanism, assessmentSection), new RingtoetsPipingSurfaceLinesContext(failureMechanism.SurfaceLines, failureMechanism, assessmentSection), - new StochasticSoilModelsContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection), + new StochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection), failureMechanism.InputComments }; } Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/StochasticSoilModelCollectionContextTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/StochasticSoilModelCollectionContextTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/StochasticSoilModelCollectionContextTest.cs (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -0,0 +1,89 @@ +// 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; +using Core.Common.Controls.PresentationObjects; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Forms.PresentationObjects; + +namespace Ringtoets.Piping.Forms.Test.PresentationObjects +{ + [TestFixture] + public class StochasticSoilModelCollectionContextTest + { + [Test] + public void ParameteredConstructor_DefaultValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + // Call + var context = new StochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSectionMock); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(failureMechanism.StochasticSoilModels, context.WrappedData); + Assert.AreSame(failureMechanism, context.FailureMechanism); + Assert.AreSame(assessmentSectionMock, context.AssessmentSection); + mocks.VerifyAll(); + } + + [Test] + public void ParameteredConstructor_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); + + var stochasticSoilModels = new StochasticSoilModelCollection(); + + // Call + TestDelegate test = () => new StochasticSoilModelCollectionContext(stochasticSoilModels, null, assessmentSectionMock); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void ParameteredConstructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + + // Call + TestDelegate test = () => new StochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + } +} \ No newline at end of file Fisheye: Tag dc682a1792664507e869ee5ecda02a9cff5426ea refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/StochasticSoilModelsContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/StochasticSoilModelCollectionPropertiesTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/StochasticSoilModelCollectionPropertiesTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/StochasticSoilModelCollectionPropertiesTest.cs (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -0,0 +1,92 @@ +// 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; +using System.ComponentModel; +using Core.Common.Base.Geometry; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Forms.PropertyClasses; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.Forms.Test.PropertyClasses +{ + [TestFixture] + public class StochasticSoilModelCollectionPropertiesTest + { + + [Test] + public void Constructor_WithoutColleciton_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new StochasticSoilModelCollectionProperties(null); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("collection", paramName); + } + + [Test] + public void Constructor_WithData_ReturnExpectedValues() + { + // Setup + var someFilePath = "location/to/a/file"; + var collection = new StochasticSoilModelCollection + { + LastKnownFilePath = someFilePath + }; + + // Call + var properties = new StochasticSoilModelCollectionProperties(collection); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.AreSame(collection, properties.Data); + Assert.AreEqual(someFilePath, properties.LastKnownFilePath); + } + + [Test] + public void Constructor_WithData_PropertiesHaveExpectedAttributesValues() + { + // Setup + var collection = new StochasticSoilModelCollection(); + + // Call + var properties = new StochasticSoilModelCollectionProperties(collection); + + // Assert + var dynamicPropertyBag = new DynamicPropertyBag(properties); + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[] + { + BrowsableAttribute.Yes + }); + Assert.AreEqual(1, dynamicProperties.Count); + + PropertyDescriptor stochasticSoilModelIdProperty = dynamicProperties[0]; + Assert.IsNotNull(stochasticSoilModelIdProperty); + Assert.IsTrue(stochasticSoilModelIdProperty.IsReadOnly); + Assert.AreEqual("Algemeen", stochasticSoilModelIdProperty.Category); + Assert.AreEqual("Bestandslocatie", stochasticSoilModelIdProperty.DisplayName); + Assert.AreEqual("De laatst bekende bestandslocatie.", stochasticSoilModelIdProperty.Description); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj =================================================================== diff -u -rb9a59dd5f30c8de46d0cabb4e1609c09176a4246 -rdc682a1792664507e869ee5ecda02a9cff5426ea --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision b9a59dd5f30c8de46d0cabb4e1609c09176a4246) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -67,9 +67,10 @@ - + + Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/StochasticSoilModelCollectionContextImportInfoTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/StochasticSoilModelCollectionContextImportInfoTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/StochasticSoilModelCollectionContextImportInfoTest.cs (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -0,0 +1,172 @@ +// 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.Drawing; +using System.IO; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Common.Base.IO; +using Core.Common.Gui.Plugin; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Forms.PresentationObjects; +using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; + +namespace Ringtoets.Piping.Plugin.Test.ImportInfos +{ + [TestFixture] + public class StochasticSoilModelCollectionContextImportInfoTest + { + private ImportInfo importInfo; + private PipingPlugin plugin; + + [SetUp] + public void SetUp() + { + plugin = new PipingPlugin(); + importInfo = plugin.GetImportInfos().First(i => i.DataType == typeof(StochasticSoilModelCollectionContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Name_Always_ReturnExpectedName() + { + // Call + string name = importInfo.Name; + + // Assert + Assert.AreEqual("Stochastische ondergrondmodellen", name); + } + + [Test] + public void Category_Always_ReturnExpectedCategory() + { + // Call + string category = importInfo.Category; + + // Assert + Assert.AreEqual("Algemeen", category); + } + + [Test] + public void Image_Always_ReturnExpectedIcon() + { + // Call + Image image = importInfo.Image; + + // Assert + TestHelper.AssertImagesAreEqual(PipingFormsResources.PipingSoilProfileIcon, image); + } + + [Test] + public void IsEnabled_ReferenceLineNull_ReturnFalse() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + assessmentSection.ReferenceLine = null; + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + var context = new StochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); + + // Call + bool isEnabled = importInfo.IsEnabled(context); + + // Assert + Assert.IsFalse(isEnabled); + mocks.VerifyAll(); + } + + [Test] + public void IsEnabled_ReferenceLineSet_ReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + assessmentSection.ReferenceLine = new ReferenceLine(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + var context = new StochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); + + // Call + bool isEnabled = importInfo.IsEnabled(context); + + // Assert + Assert.IsTrue(isEnabled); + mocks.VerifyAll(); + } + + [Test] + public void FileFilter_Always_ReturnExpectedFileFilter() + { + // Call + string fileFilter = importInfo.FileFilter; + + // Assert + Assert.AreEqual("D-Soil Model bestand (*.soil)|*.soil", fileFilter); + } + + [Test] + public void CreateFileImporter_ValidInput_SuccessfulImport() + { + // Setup + var filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, + Path.Combine("PipingSoilProfilesReader", "complete.soil")); + + var referenceLine = new ReferenceLine(); + referenceLine.SetGeometry(new[] + { + new Point2D(3.3, -1), + new Point2D(3.3, 1), + new Point2D(94270, 427775.65), + new Point2D(94270, 427812.08) + }); + + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + assessmentSection.ReferenceLine = referenceLine; + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + var importTarget = new StochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); + + // Call + IFileImporter importer = importInfo.CreateFileImporter(importTarget, filePath); + + // Assert + Assert.IsTrue(importer.Import()); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Fisheye: Tag dc682a1792664507e869ee5ecda02a9cff5426ea refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/StochasticSoilModelsContextImportInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingPluginTest.cs =================================================================== diff -u -r6e56258ed65fb071d7dac5a9df4e71196542a392 -rdc682a1792664507e869ee5ecda02a9cff5426ea --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 6e56258ed65fb071d7dac5a9df4e71196542a392) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -66,7 +66,7 @@ PropertyInfo[] propertyInfos = plugin.GetPropertyInfos().ToArray(); // Assert - Assert.AreEqual(6, propertyInfos.Length); + Assert.AreEqual(7, propertyInfos.Length); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, @@ -90,6 +90,11 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, + typeof(StochasticSoilModelCollectionContext), + typeof(StochasticSoilModelCollectionProperties)); + + PluginTestHelper.AssertPropertyInfoDefined( + propertyInfos, typeof(StochasticSoilModel), typeof(StochasticSoilModelProperties)); @@ -123,7 +128,7 @@ Assert.AreEqual(13, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(RingtoetsPipingSurfaceLinesContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(RingtoetsPipingSurfaceLine))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StochasticSoilModelsContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StochasticSoilModelCollectionContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StochasticSoilModel))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StochasticSoilProfile))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingCalculationScenarioContext))); @@ -187,7 +192,7 @@ // Assert Assert.AreEqual(2, importInfos.Length); Assert.AreEqual(1, importInfos.Count(i => i.DataType == typeof(RingtoetsPipingSurfaceLinesContext))); - Assert.AreEqual(1, importInfos.Count(i => i.DataType == typeof(StochasticSoilModelsContext))); + Assert.AreEqual(1, importInfos.Count(i => i.DataType == typeof(StochasticSoilModelCollectionContext))); } mocks.VerifyAll(); } Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/PipingInputContextPropertyInfoTest.cs =================================================================== diff -u -rc48f16746209f799f93c6fc79a5202a9e3fd419f -rdc682a1792664507e869ee5ecda02a9cff5426ea --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/PipingInputContextPropertyInfoTest.cs (.../PipingInputContextPropertyInfoTest.cs) (revision c48f16746209f799f93c6fc79a5202a9e3fd419f) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/PipingInputContextPropertyInfoTest.cs (.../PipingInputContextPropertyInfoTest.cs) (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -33,7 +33,6 @@ { [TestFixture] public class PipingInputContextPropertyInfoTest - { private PipingPlugin plugin; private PropertyInfo info; Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/StochasticSoilModelCollectionContextPropertyInfoTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/StochasticSoilModelCollectionContextPropertyInfoTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/StochasticSoilModelCollectionContextPropertyInfoTest.cs (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -0,0 +1,83 @@ +// 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.Linq; +using Core.Common.Gui.Plugin; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Forms.PresentationObjects; +using Ringtoets.Piping.Forms.PropertyClasses; + +namespace Ringtoets.Piping.Plugin.Test.PropertyInfos +{ + [TestFixture] + public class StochasticSoilModelCollectionContextPropertyInfoTest + { + private PipingPlugin plugin; + private PropertyInfo info; + + [SetUp] + public void SetUp() + { + plugin = new PipingPlugin(); + info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(StochasticSoilModelCollectionProperties)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(StochasticSoilModelCollectionContext), info.DataType); + Assert.AreEqual(typeof(StochasticSoilModelCollectionProperties), info.PropertyObjectType); + } + + [Test] + public void CreateInstance_Always_NewPropertiesWithInputContextAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + var collection = new StochasticSoilModelCollection(); + var context = new StochasticSoilModelCollectionContext(collection, failureMechanism, assessmentSection); + + // Call + var objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(collection, objectProperties.Data); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj =================================================================== diff -u -r6ddd27897f8c0d4b1e3c4b720e06df9dd855aaf8 -rdc682a1792664507e869ee5ecda02a9cff5426ea --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 6ddd27897f8c0d4b1e3c4b720e06df9dd855aaf8) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -76,9 +76,10 @@ - + + @@ -91,7 +92,7 @@ - + Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rf2f7d22ee59276f5df1f83fd409899bd895ea163 -rdc682a1792664507e869ee5ecda02a9cff5426ea --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs (.../PipingFailureMechanismContextTreeNodeInfoTest.cs) (revision f2f7d22ee59276f5df1f83fd409899bd895ea163) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs (.../PipingFailureMechanismContextTreeNodeInfoTest.cs) (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -161,7 +161,7 @@ Assert.AreSame(pipingFailureMechanism, surfaceLinesContext.FailureMechanism); Assert.AreSame(assessmentSection, surfaceLinesContext.AssessmentSection); - var stochasticSoilModelContext = (StochasticSoilModelsContext) inputsFolder.Contents[2]; + var stochasticSoilModelContext = (StochasticSoilModelCollectionContext) inputsFolder.Contents[2]; Assert.AreSame(pipingFailureMechanism, stochasticSoilModelContext.FailureMechanism); Assert.AreSame(pipingFailureMechanism, stochasticSoilModelContext.FailureMechanism); Assert.AreSame(assessmentSection, stochasticSoilModelContext.AssessmentSection); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -0,0 +1,228 @@ +// 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; +using Core.Common.Gui; +using Core.Common.Gui.ContextMenu; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Forms.PresentationObjects; +using Ringtoets.Piping.Forms.Properties; +using Ringtoets.Piping.Primitives; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Piping.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class StochasticSoilModelCollectionContextTreeNodeInfoTest + { + private MockRepository mocks; + private PipingPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new PipingPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StochasticSoilModelCollectionContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocks.ReplayAll(); + + // Assert + Assert.IsNotNull(info.Text); + Assert.IsNotNull(info.ForeColor); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ContextMenuStrip); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ExpandOnCreate); + Assert.IsNotNull(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_ReturnsTextFromResource() + { + // Setup + var failureMechanismMock = mocks.StrictMock(); + var assessmentSectionMock = mocks.StrictMock(); + var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock.StochasticSoilModels, failureMechanismMock, assessmentSectionMock); + mocks.ReplayAll(); + + // Call + var text = info.Text(stochasticSoilModelContextMock); + + // Assert + Assert.AreEqual(Resources.StochasticSoilModelCollection_DisplayName, text); + } + + [Test] + public void Image_Always_ReturnsSetImage() + { + // Setup + var failureMechanismMock = mocks.StrictMock(); + var assessmentSectionMock = mocks.StrictMock(); + var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock.StochasticSoilModels, failureMechanismMock, assessmentSectionMock); + mocks.ReplayAll(); + + // Call + var image = info.Image(stochasticSoilModelContextMock); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralFolderIcon, image); + } + + [Test] + public void ForeColor_CollectionWithoutSoilProfiles_ReturnsGrayText() + { + // Setup + var failureMechanismMock = mocks.StrictMock(); + var assessmentSectionMock = mocks.StrictMock(); + var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock.StochasticSoilModels, failureMechanismMock, assessmentSectionMock); + mocks.ReplayAll(); + + // Call + var foreColor = info.ForeColor(stochasticSoilModelContextMock); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), foreColor); + } + + [Test] + public void ForeColor_CollectionWithSoilProfiles_ReturnsControlText() + { + // Setup + var failureMechanismMock = mocks.StrictMock(); + var assessmentSectionMock = mocks.StrictMock(); + var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock.StochasticSoilModels, failureMechanismMock, assessmentSectionMock); + failureMechanismMock.StochasticSoilModels.Add(new StochasticSoilModel(0, "Name", "Name")); + mocks.ReplayAll(); + + // Call + var foreColor = info.ForeColor(stochasticSoilModelContextMock); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), foreColor); + } + + [Test] + public void ChildNodeObjects_Always_ReturnsChildrenOfData() + { + // Setup + var pipingSoilProfile1 = new PipingSoilProfile("pipingSoilProfile1", 0, new List + { + new PipingSoilLayer(10) + }, SoilProfileType.SoilProfile1D, 0); + var pipingSoilProfile2 = new PipingSoilProfile("pipingSoilProfile2", 0, new List + { + new PipingSoilLayer(10) + }, SoilProfileType.SoilProfile1D, 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.StochasticSoilModels, failureMechanismMock, assessmentSectionMock); + failureMechanismMock.StochasticSoilModels.Add(stochasticSoilModel); + + mocks.ReplayAll(); + + // Call + var objects = info.ChildNodeObjects(stochasticSoilModelContextMock); + + // Assert + CollectionAssert.AreEqual(new[] + { + stochasticSoilModel + }, objects); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var menuBuilderMock = mocks.StrictMock(); + + using (mocks.Ordered()) + { + menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddDeleteChildrenItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + } + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(null, null, treeViewControl); + } + // Assert + // Assert expectancies are called in TearDown() + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelTreeNodeInfoTest.cs =================================================================== diff -u -rf2f7d22ee59276f5df1f83fd409899bd895ea163 -rdc682a1792664507e869ee5ecda02a9cff5426ea --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelTreeNodeInfoTest.cs (.../StochasticSoilModelTreeNodeInfoTest.cs) (revision f2f7d22ee59276f5df1f83fd409899bd895ea163) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelTreeNodeInfoTest.cs (.../StochasticSoilModelTreeNodeInfoTest.cs) (revision dc682a1792664507e869ee5ecda02a9cff5426ea) @@ -151,7 +151,7 @@ mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); - var parentData = new StochasticSoilModelsContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); + var parentData = new StochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call bool canRemove = info.CanRemove(null, parentData); @@ -258,7 +258,7 @@ }; failureMechanism.StochasticSoilModels.Attach(observer); - var parentData = new StochasticSoilModelsContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); + var parentData = new StochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call info.OnNodeRemoved(nodeData, parentData); Fisheye: Tag dc682a1792664507e869ee5ecda02a9cff5426ea refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelsContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff?