Index: Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs =================================================================== diff -u -r887b289acf19a81f62d78f371ab70c3f82812b95 -rd148009f276fb1d4a7a4cbacb730c31114b7e4ae --- Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (.../AddNewDemoAssessmentSectionCommandTest.cs) (revision 887b289acf19a81f62d78f371ab70c3f82812b95) +++ Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (.../AddNewDemoAssessmentSectionCommandTest.cs) (revision d148009f276fb1d4a7a4cbacb730c31114b7e4ae) @@ -9,7 +9,7 @@ using Demo.Ringtoets.Commands; using NUnit.Framework; using Rhino.Mocks; -using Ringtoets.Common.Data; +using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; Index: Ringtoets/Common/src/Ringtoets.Common.Data/Calculation/CalculationGroupExtensions.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Data/Calculation/CalculationGroupExtensions.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Calculation/CalculationGroupExtensions.cs (revision d148009f276fb1d4a7a4cbacb730c31114b7e4ae) @@ -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 System.Collections.Generic; + +namespace Ringtoets.Common.Data.Calculation +{ + /// + /// Defines extension methods dealing with instances. + /// + public static class CalculationGroupExtensions + { + /// + /// Recursively enumerates across the contents of the piping calculation item, + /// yielding the piping calculations found within the calculation item. + /// + /// The calculation group to be evaluated. + /// Returns all contained piping calculations as an enumerable result. + public static IEnumerable GetCalculations(this CalculationGroup calculationGroup) + { + var calculationScenarios = new List(); + foreach (ICalculationBase calculationItem in calculationGroup.Children) + { + var calculationScenario = calculationItem as ICalculationScenario; + if (calculationScenario != null) + { + calculationScenarios.Add(calculationScenario); + } + + var nestedCalculationGroup = calculationItem as CalculationGroup; + if (nestedCalculationGroup != null) + { + calculationScenarios.AddRange(GetCalculations(nestedCalculationGroup)); + } + } + return calculationScenarios; + } + } +} \ No newline at end of file Fisheye: Tag d148009f276fb1d4a7a4cbacb730c31114b7e4ae refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Data/ICalculationBaseExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj =================================================================== diff -u -rfff12e249602fb700b2854c14a3b7cdd0b73c023 -rd148009f276fb1d4a7a4cbacb730c31114b7e4ae --- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision fff12e249602fb700b2854c14a3b7cdd0b73c023) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision d148009f276fb1d4a7a4cbacb730c31114b7e4ae) @@ -55,7 +55,7 @@ - + Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Calculation/CalculationGroupExtensionsTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Calculation/CalculationGroupExtensionsTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Calculation/CalculationGroupExtensionsTest.cs (revision d148009f276fb1d4a7a4cbacb730c31114b7e4ae) @@ -0,0 +1,105 @@ +// 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 NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.Calculation; + +namespace Ringtoets.Common.Data.Test.Calculation +{ + [TestFixture] + public class CalculationGroupExtensionsTest + { + [Test] + public void GetCalculations_FromCalculationGroupWithoutChildren_ReturnEmpty() + { + // Setup + CalculationGroup groupWithoutChildren = new CalculationGroup(); + + // Call + IEnumerable result = groupWithoutChildren.GetCalculations(); + + // Assert + CollectionAssert.IsEmpty(result); + } + + [Test] + public void GetCalculations_FromCalculationGroupWithEmptyGroups_ReturnEmpty() + { + // Setup + var rootGroup = new CalculationGroup(); + rootGroup.Children.Add(new CalculationGroup()); + rootGroup.Children.Add(new CalculationGroup()); + rootGroup.Children.Add(new CalculationGroup()); + + CalculationGroup groupsWithoutChildren = rootGroup; + + // Call + IEnumerable result = groupsWithoutChildren.GetCalculations(); + + // Assert + CollectionAssert.IsEmpty(result); + } + + [Test] + public void GetCalculations_FromCalculationGroupWithGroupsAndCalculations_ReturnAllCalculationsRecursiveslyInAnyOrder() + { + // Setup + var mocks = new MockRepository(); + ICalculationBase calculation1 = mocks.StrictMock(); + ICalculationBase calculation2 = mocks.StrictMock(); + ICalculationBase calculation3 = mocks.StrictMock(); + ICalculationBase calculation4 = mocks.StrictMock(); + mocks.ReplayAll(); + + var subsubGroup = new CalculationGroup(); + subsubGroup.Children.Add(calculation4); + + var subgroup1 = new CalculationGroup(); + subgroup1.Children.Add(calculation2); + subgroup1.Children.Add(subsubGroup); + + var subgroup2 = new CalculationGroup(); + subgroup2.Children.Add(calculation3); + + var rootGroup = new CalculationGroup(); + rootGroup.Children.Add(subgroup1); + rootGroup.Children.Add(calculation1); + rootGroup.Children.Add(subgroup2); + + CalculationGroup groupWithoutChildren = rootGroup; + + // Call + IEnumerable result = groupWithoutChildren.GetCalculations(); + + // Assert + var itemsThatShouldBeFound = new[] + { + calculation1, + calculation2, + calculation3, + calculation4 + }; + CollectionAssert.AreEquivalent(itemsThatShouldBeFound, result); + } + } +} \ No newline at end of file Fisheye: Tag d148009f276fb1d4a7a4cbacb730c31114b7e4ae refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Data.Test/ICalculationBaseExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj =================================================================== diff -u -rf5e1194ee412e86277cee388a75c39db189f2b3e -rd148009f276fb1d4a7a4cbacb730c31114b7e4ae --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision f5e1194ee412e86277cee388a75c39db189f2b3e) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision d148009f276fb1d4a7a4cbacb730c31114b7e4ae) @@ -65,7 +65,7 @@ - + Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingCalculationConfigurationHelper.cs =================================================================== diff -u -rfff12e249602fb700b2854c14a3b7cdd0b73c023 -rd148009f276fb1d4a7a4cbacb730c31114b7e4ae --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingCalculationConfigurationHelper.cs (.../PipingCalculationConfigurationHelper.cs) (revision fff12e249602fb700b2854c14a3b7cdd0b73c023) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingCalculationConfigurationHelper.cs (.../PipingCalculationConfigurationHelper.cs) (revision d148009f276fb1d4a7a4cbacb730c31114b7e4ae) @@ -25,7 +25,6 @@ using Core.Common.Base.Data; using Core.Common.Base.Geometry; using log4net; -using Ringtoets.Common.Data; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Piping.Data; @@ -78,7 +77,7 @@ throw new ArgumentNullException("normProbabilityInput"); } - List groups = new List(); + List groups = new List(); foreach (var surfaceLine in surfaceLines) { var group = CreateCalculationGroup(surfaceLine, soilModels, generalInput, normProbabilityInput); @@ -124,19 +123,19 @@ return soilModelObjectsForCalculation; } - private static ICalculationBase CreateCalculationGroup(RingtoetsPipingSurfaceLine surfaceLine, IEnumerable soilModels, GeneralPipingInput generalInput, NormProbabilityPipingInput normProbabilityInput) + private static CalculationGroup CreateCalculationGroup(RingtoetsPipingSurfaceLine surfaceLine, IEnumerable soilModels, GeneralPipingInput generalInput, NormProbabilityPipingInput normProbabilityInput) { - var pipingCalculationGroup = new CalculationGroup(surfaceLine.Name, true); + var calculationGroup = new CalculationGroup(surfaceLine.Name, true); var stochasticSoilModels = GetStochasticSoilModelsForSurfaceLine(surfaceLine, soilModels); foreach (var stochasticSoilModel in stochasticSoilModels) { foreach (var soilProfile in stochasticSoilModel.StochasticSoilProfiles) { - pipingCalculationGroup.Children.Add(CreatePipingCalculation(surfaceLine, stochasticSoilModel, soilProfile, pipingCalculationGroup.Children, generalInput, normProbabilityInput)); + calculationGroup.Children.Add(CreatePipingCalculation(surfaceLine, stochasticSoilModel, soilProfile, calculationGroup.Children, generalInput, normProbabilityInput)); } } - return pipingCalculationGroup; + return calculationGroup; } private static ICalculationBase CreatePipingCalculation(RingtoetsPipingSurfaceLine surfaceLine, StochasticSoilModel stochasticSoilModel, StochasticSoilProfile stochasticSoilProfile, IEnumerable calculations, GeneralPipingInput generalInput, NormProbabilityPipingInput normProbabilityInput)