Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsCalculationContextTest.cs =================================================================== diff -u -re775448bfb8290e43d62340a53a08723bbc035c6 -r04012135e8adf6a03ce2928e047603435c9a186f --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsCalculationContextTest.cs (.../GrassCoverErosionInwardsCalculationContextTest.cs) (revision e775448bfb8290e43d62340a53a08723bbc035c6) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsCalculationContextTest.cs (.../GrassCoverErosionInwardsCalculationContextTest.cs) (revision 04012135e8adf6a03ce2928e047603435c9a186f) @@ -48,9 +48,9 @@ // Assert Assert.IsInstanceOf>(context); Assert.IsInstanceOf>(context); - Assert.AreEqual(calculation, context.WrappedData); - Assert.AreEqual(failureMechanism, context.FailureMechanism); - Assert.AreEqual(assessmentSectionMock, context.AssessmentSection); + Assert.AreSame(calculation, context.WrappedData); + Assert.AreSame(failureMechanism, context.FailureMechanism); + Assert.AreSame(assessmentSectionMock, context.AssessmentSection); mocksRepository.VerifyAll(); } } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsInputContextTest.cs =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -r04012135e8adf6a03ce2928e047603435c9a186f --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsInputContextTest.cs (.../GrassCoverErosionInwardsInputContextTest.cs) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsInputContextTest.cs (.../GrassCoverErosionInwardsInputContextTest.cs) (revision 04012135e8adf6a03ce2928e047603435c9a186f) @@ -58,10 +58,10 @@ // Assert Assert.IsInstanceOf>(context); - Assert.AreEqual(input, context.WrappedData); - Assert.AreEqual(calculation, context.Calculation); - Assert.AreEqual(failureMechanism, context.FailureMechanism); - Assert.AreEqual(assessmentSectionMock, context.AssessmentSection); + Assert.AreSame(input, context.WrappedData); + Assert.AreSame(calculation, context.Calculation); + Assert.AreSame(failureMechanism, context.FailureMechanism); + Assert.AreSame(assessmentSectionMock, context.AssessmentSection); mocksRepository.VerifyAll(); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rae14c5d4e4624fa87390e6d63bb419c648e12dda -r04012135e8adf6a03ce2928e047603435c9a186f --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision ae14c5d4e4624fa87390e6d63bb419c648e12dda) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision 04012135e8adf6a03ce2928e047603435c9a186f) @@ -220,8 +220,6 @@ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(MacrostabilityInwardsFailureMechanismSectionResult)")] [TestCase(typeof(MacrostabilityOutwardsFailureMechanismSectionResult), TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(MacrostabilityOutwardsFailureMechanismSectionResult)")] - [TestCase(typeof(StabilityPointStructuresFailureMechanismSectionResult), - TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(StabilityPointStructuresFailureMechanismSectionResult)")] public void ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(Type t) { // Delegate actual test Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresCalculationContext.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresCalculationContext.cs (revision 0) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresCalculationContext.cs (revision 04012135e8adf6a03ce2928e047603435c9a186f) @@ -0,0 +1,49 @@ +// 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 Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.StabilityPointStructures.Data; + +namespace Ringtoets.StabilityPointStructures.Forms.PresentationObjects +{ + /// + /// Presentation object for all data required to configure an instance of + /// in order to prepare it for performing a calculation. + /// + public class StabilityPointStructuresCalculationContext : StabilityPointStructuresContext, + ICalculationContext + { + /// + /// Creates a new instance of . + /// + /// The instance wrapped by this context object. + /// The failure mechanism which the context belongs to. + /// The assessment section which the calculation belongs to. + /// When any input argument is null. + public StabilityPointStructuresCalculationContext(StabilityPointStructuresCalculation calculation, + StabilityPointStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + : base(calculation, failureMechanism, assessmentSection) {} + } +} \ No newline at end of file Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresInputContext.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresInputContext.cs (revision 0) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresInputContext.cs (revision 04012135e8adf6a03ce2928e047603435c9a186f) @@ -0,0 +1,61 @@ +// 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 Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.StabilityPointStructures.Data; + +namespace Ringtoets.StabilityPointStructures.Forms.PresentationObjects +{ + /// + /// Presentation object for all data required to configure an instance of + /// in order to be able to configure stability point structures calculations. + /// + public class StabilityPointStructuresInputContext : StabilityPointStructuresContext + { + /// + /// Creates a new instance of . + /// + /// The stability point structures input instance wrapped by this context object. + /// The calculation item which the belongs to. + /// The failure mechanism which the context belongs to. + /// The assessment section which the context belongs to. + /// When any input argument is null. + public StabilityPointStructuresInputContext(StabilityPointStructuresInput input, + StabilityPointStructuresCalculation calculation, + StabilityPointStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + : base(input, failureMechanism, assessmentSection) + { + if (calculation == null) + { + throw new ArgumentNullException("calculation"); + } + + Calculation = calculation; + } + + /// + /// Gets the calculation item which the context belongs to. + /// + public StabilityPointStructuresCalculation Calculation { get; private set; } + } +} \ No newline at end of file Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Ringtoets.StabilityPointStructures.Forms.csproj =================================================================== diff -u -rfe8e564d0114932ff274b9c4e3066639ae2f02f1 -r04012135e8adf6a03ce2928e047603435c9a186f --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Ringtoets.StabilityPointStructures.Forms.csproj (.../Ringtoets.StabilityPointStructures.Forms.csproj) (revision fe8e564d0114932ff274b9c4e3066639ae2f02f1) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Ringtoets.StabilityPointStructures.Forms.csproj (.../Ringtoets.StabilityPointStructures.Forms.csproj) (revision 04012135e8adf6a03ce2928e047603435c9a186f) @@ -40,9 +40,11 @@ Properties\GlobalAssembly.cs + + UserControl Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/Ringtoets.StabilityPointStructures.Plugin.csproj =================================================================== diff -u -rfe8e564d0114932ff274b9c4e3066639ae2f02f1 -r04012135e8adf6a03ce2928e047603435c9a186f --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/Ringtoets.StabilityPointStructures.Plugin.csproj (.../Ringtoets.StabilityPointStructures.Plugin.csproj) (revision fe8e564d0114932ff274b9c4e3066639ae2f02f1) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/Ringtoets.StabilityPointStructures.Plugin.csproj (.../Ringtoets.StabilityPointStructures.Plugin.csproj) (revision 04012135e8adf6a03ce2928e047603435c9a186f) @@ -85,6 +85,21 @@ Ringtoets.Common.Forms False + + {d951d6da-fe83-4920-9fdb-63bf96480b54} + Ringtoets.Common.Service + False + + + {70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2} + Ringtoets.HydraRing.Data + False + + + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70} + Ringtoets.HydraRing.IO + False + {3D4B9740-8348-4434-8D77-B611FC6EE57F} Ringtoets.StabilityPointStructures.Data Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs =================================================================== diff -u -r0c5413891f455d0884393e14f8afea6b2625b72e -r04012135e8adf6a03ce2928e047603435c9a186f --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 0c5413891f455d0884393e14f8afea6b2625b72e) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 04012135e8adf6a03ce2928e047603435c9a186f) @@ -29,15 +29,18 @@ using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TreeNodeInfos; +using Ringtoets.HydraRing.IO; using Ringtoets.StabilityPointStructures.Data; using Ringtoets.StabilityPointStructures.Forms.PresentationObjects; using Ringtoets.StabilityPointStructures.Forms.Views; using Ringtoets.StabilityPointStructures.Plugin.Properties; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; using StabilityPointStructuresDataResources = Ringtoets.StabilityPointStructures.Data.Properties.Resources; +using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; namespace Ringtoets.StabilityPointStructures.Plugin { @@ -85,8 +88,54 @@ CalculationGroupContextChildNodeObjects, CalculationGroupContextContextMenuStrip, CalculationGroupContextOnNodeRemoved); + + yield return RingtoetsTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo( + CalculationContextChildNodeObjects, + CalculationContextContextMenuStrip, + CalculationContextOnNodeRemoved); + + yield return new TreeNodeInfo + { + Text = inputContext => RingtoetsCommonFormsResources.Calculation_Input, + Image = inputContext => RingtoetsCommonFormsResources.GenericInputOutputIcon, + ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddOpenItem() + .AddSeparator() + .AddPropertiesItem() + .Build() + }; + + yield return new TreeNodeInfo + { + Text = output => RingtoetsCommonFormsResources.CalculationOutput_DisplayName, + Image = output => RingtoetsCommonFormsResources.GeneralOutputIcon, + ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddPropertiesItem() + .Build() + }; } + private static string ValidateAllDataAvailableAndGetErrorMessage(IAssessmentSection assessmentSection, StabilityPointStructuresFailureMechanism failureMechanism) + { + if (!failureMechanism.Sections.Any()) + { + return RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported; + } + + if (assessmentSection.HydraulicBoundaryDatabase == null) + { + return RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_hydraulic_boundary_database_imported; + } + + var validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(assessmentSection.HydraulicBoundaryDatabase.FilePath); + if (!string.IsNullOrEmpty(validationProblem)) + { + return string.Format(RingtoetsCommonServiceResources.Hydraulic_boundary_database_connection_failed_0_, validationProblem); + } + + return null; + } + #region ViewInfo #region StabilityPointStructuresFailureMechanismResultView ViewInfo @@ -160,7 +209,7 @@ return builder.AddToggleRelevancyOfFailureMechanismItem(failureMechanismContext, RemoveAllViewsForItem) .AddSeparator() - .AddValidateAllCalculationsInFailureMechanismItem(failureMechanismContext,null) + .AddValidateAllCalculationsInFailureMechanismItem(failureMechanismContext, null) .AddPerformAllCalculationsInFailureMechanismItem(failureMechanismContext, null) .AddClearAllCalculationOutputInFailureMechanismItem(failureMechanismContext.WrappedData) .AddSeparator() @@ -197,9 +246,17 @@ foreach (ICalculationBase calculationItem in context.WrappedData.Children) { + var calculation = calculationItem as StabilityPointStructuresCalculation; var group = calculationItem as CalculationGroup; - if (group != null) + + if (calculation != null) { + childNodeObjects.Add(new StabilityPointStructuresCalculationContext(calculation, + context.FailureMechanism, + context.AssessmentSection)); + } + else if (group != null) + { childNodeObjects.Add(new StabilityPointStructuresCalculationGroupContext(group, context.FailureMechanism, context.AssessmentSection)); @@ -276,10 +333,83 @@ parentGroupContext.NotifyObservers(); } - private static void AddCalculation(StabilityPointStructuresCalculationGroupContext context) {} + private static void AddCalculation(StabilityPointStructuresCalculationGroupContext context) + { + var calculation = new StabilityPointStructuresCalculation + { + Name = NamingHelper.GetUniqueName(context.WrappedData.Children, StabilityPointStructuresDataResources.StabilityPointStructuresCalculation_DefaultName, c => c.Name) + }; + context.WrappedData.Children.Add(calculation); + context.WrappedData.NotifyObservers(); + } #endregion + #region StabilityPointStructuresCalculationContext TreeNodeInfo + + private static object[] CalculationContextChildNodeObjects(StabilityPointStructuresCalculationContext context) + { + var childNodes = new List + { + new CommentContext(context.WrappedData), + new StabilityPointStructuresInputContext(context.WrappedData.InputParameters, + context.WrappedData, + context.FailureMechanism, + context.AssessmentSection) + }; + + if (context.WrappedData.HasOutput) + { + childNodes.Add(context.WrappedData.Output); + } + else + { + // childNodes.Add(new EmptyProbabilityAssessmentOutput()); + } + + return childNodes.ToArray(); + } + + private ContextMenuStrip CalculationContextContextMenuStrip(StabilityPointStructuresCalculationContext context, object parentData, TreeViewControl treeViewControl) + { + var builder = new RingtoetsContextMenuBuilder(Gui.Get(context, treeViewControl)); + + StabilityPointStructuresCalculation calculation = context.WrappedData; + + return builder.AddValidateCalculationItem(context, delegate { }) + .AddPerformCalculationItem(calculation, context, Calculate) + .AddClearCalculationOutputItem(calculation) + .AddSeparator() + .AddRenameItem() + .AddDeleteItem() + .AddSeparator() + .AddExpandAllItem() + .AddCollapseAllItem() + .AddSeparator() + .AddPropertiesItem() + .Build(); + } + + private static string ValidateAllDataAvailableAndGetErrorMessageForCalculation(StabilityPointStructuresCalculationContext context) + { + return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection, context.FailureMechanism); + } + + private void Calculate(StabilityPointStructuresCalculation calculation, StabilityPointStructuresCalculationContext context) {} + + private void CalculationContextOnNodeRemoved(StabilityPointStructuresCalculationContext context, object parentData) + { + var calculationGroupContext = parentData as StabilityPointStructuresCalculationGroupContext; + if (calculationGroupContext != null) + { + calculationGroupContext.WrappedData.Children.Remove(context.WrappedData); + //AssignUnassignCalculations.Delete(context.FailureMechanism.SectionResults, context.WrappedData, context.FailureMechanism.Calculations.OfType()); + calculationGroupContext.NotifyObservers(); + } + } + #endregion + + #endregion } } \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresCalculationContextTest.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresCalculationContextTest.cs (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresCalculationContextTest.cs (revision 04012135e8adf6a03ce2928e047603435c9a186f) @@ -0,0 +1,57 @@ +// 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 NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.StabilityPointStructures.Data; +using Ringtoets.StabilityPointStructures.Forms.PresentationObjects; + +namespace Ringtoets.StabilityPointStructures.Forms.Test.PresentationObjects +{ + [TestFixture] + public class StabilityPointStructuresCalculationContextTest + { + [Test] + public void ConstructorWithData_Always_ExpectedPropertiesSet() + { + // Setup + var mocksRepository = new MockRepository(); + var assessmentSectionMock = mocksRepository.StrictMock(); + mocksRepository.ReplayAll(); + + var calculation = new StabilityPointStructuresCalculation(); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + // Call + var context = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); + + // Assert + Assert.IsInstanceOf>(context); + Assert.IsInstanceOf>(context); + Assert.AreSame(calculation, context.WrappedData); + Assert.AreSame(failureMechanism, context.FailureMechanism); + Assert.AreSame(assessmentSectionMock, context.AssessmentSection); + mocksRepository.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresInputContextTest.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresInputContextTest.cs (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresInputContextTest.cs (revision 04012135e8adf6a03ce2928e047603435c9a186f) @@ -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; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.StabilityPointStructures.Data; +using Ringtoets.StabilityPointStructures.Forms.PresentationObjects; + +namespace Ringtoets.StabilityPointStructures.Forms.Test.PresentationObjects +{ + public class StabilityPointStructuresInputContextTest + { + private MockRepository mocksRepository; + + [SetUp] + public void SetUp() + { + mocksRepository = new MockRepository(); + } + + [Test] + public void ConstructorWithData_Always_ExpectedPropertiesSet() + { + // Setup + var assessmentSectionMock = mocksRepository.StrictMock(); + mocksRepository.ReplayAll(); + + var input = new StabilityPointStructuresInput(); + var calculation = new StabilityPointStructuresCalculation(); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + // Call + var context = new StabilityPointStructuresInputContext(input, calculation, failureMechanism, assessmentSectionMock); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(input, context.WrappedData); + Assert.AreSame(calculation, context.Calculation); + Assert.AreSame(failureMechanism, context.FailureMechanism); + Assert.AreSame(assessmentSectionMock, context.AssessmentSection); + mocksRepository.VerifyAll(); + } + + [Test] + public void Constructor_NullCalculation_ThrowsArgumentNullException() + { + // Setup + var assessmentSectionMock = mocksRepository.StrictMock(); + mocksRepository.ReplayAll(); + + var input = new StabilityPointStructuresInput(); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + // Call + TestDelegate test = () => new StabilityPointStructuresInputContext(input, null, failureMechanism, assessmentSectionMock); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("calculation", paramName); + mocksRepository.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Ringtoets.StabilityPointStructures.Forms.Test.csproj =================================================================== diff -u -rfe8e564d0114932ff274b9c4e3066639ae2f02f1 -r04012135e8adf6a03ce2928e047603435c9a186f --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Ringtoets.StabilityPointStructures.Forms.Test.csproj (.../Ringtoets.StabilityPointStructures.Forms.Test.csproj) (revision fe8e564d0114932ff274b9c4e3066639ae2f02f1) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Ringtoets.StabilityPointStructures.Forms.Test.csproj (.../Ringtoets.StabilityPointStructures.Forms.Test.csproj) (revision 04012135e8adf6a03ce2928e047603435c9a186f) @@ -57,9 +57,11 @@ Properties\GlobalAssembly.cs + + Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/StabilityPointStructuresPluginTest.cs =================================================================== diff -u -rfe8e564d0114932ff274b9c4e3066639ae2f02f1 -r04012135e8adf6a03ce2928e047603435c9a186f --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/StabilityPointStructuresPluginTest.cs (.../StabilityPointStructuresPluginTest.cs) (revision fe8e564d0114932ff274b9c4e3066639ae2f02f1) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/StabilityPointStructuresPluginTest.cs (.../StabilityPointStructuresPluginTest.cs) (revision 04012135e8adf6a03ce2928e047603435c9a186f) @@ -68,10 +68,13 @@ TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray(); // Assert - Assert.AreEqual(3, treeNodeInfos.Length); + Assert.AreEqual(6, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityPointStructuresFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityPointStructuresCalculationGroupContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityPointStructuresCalculationContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityPointStructuresInputContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityPointStructuresOutput))); } mocks.VerifyAll();