Index: Ringtoets.sln =================================================================== diff -u -re5658f822fa85cab8e99cb3069867d3a87867386 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets.sln (.../Ringtoets.sln) (revision e5658f822fa85cab8e99cb3069867d3a87867386) +++ Ringtoets.sln (.../Ringtoets.sln) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -370,6 +370,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ringtoets.GrassCoverErosionInwards.Utils", "Ringtoets\GrassCoverErosionInwards\src\Ringtoets.GrassCoverErosionInwards.Utils\Ringtoets.GrassCoverErosionInwards.Utils.csproj", "{99573570-EE00-4264-8147-26A1B25DB23F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ringtoets.GrassCoverErosionInwards.Utils.Test", "Ringtoets\GrassCoverErosionInwards\test\Ringtoets.GrassCoverErosionInwards.Utils.Test\Ringtoets.GrassCoverErosionInwards.Utils.Test.csproj", "{5C19638A-3CC5-496F-8552-385785E728E3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution CreateInstaller|x86 = CreateInstaller|x86 @@ -1469,6 +1471,14 @@ {99573570-EE00-4264-8147-26A1B25DB23F}.Release|x86.Build.0 = Release|x86 {99573570-EE00-4264-8147-26A1B25DB23F}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86 {99573570-EE00-4264-8147-26A1B25DB23F}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86 + {5C19638A-3CC5-496F-8552-385785E728E3}.CreateInstaller|x86.ActiveCfg = Release|x86 + {5C19638A-3CC5-496F-8552-385785E728E3}.CreateInstallerWithDemoProject|x86.ActiveCfg = Release|x86 + {5C19638A-3CC5-496F-8552-385785E728E3}.Debug|x86.ActiveCfg = Debug|x86 + {5C19638A-3CC5-496F-8552-385785E728E3}.Debug|x86.Build.0 = Debug|x86 + {5C19638A-3CC5-496F-8552-385785E728E3}.Release|x86.ActiveCfg = Release|x86 + {5C19638A-3CC5-496F-8552-385785E728E3}.Release|x86.Build.0 = Release|x86 + {5C19638A-3CC5-496F-8552-385785E728E3}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86 + {5C19638A-3CC5-496F-8552-385785E728E3}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1617,6 +1627,7 @@ {632403D0-E54F-4718-A694-8AD47C4CB301} = {1C1E8754-CF61-4858-9CEE-3E5DE344474F} {BB9D13C5-2672-4F61-93B3-8EA361399BDD} = {1C1E8754-CF61-4858-9CEE-3E5DE344474F} {D7801688-3DD7-407F-9302-F4FD82B1F499} = {1C1E8754-CF61-4858-9CEE-3E5DE344474F} + {5C19638A-3CC5-496F-8552-385785E728E3} = {1C1E8754-CF61-4858-9CEE-3E5DE344474F} {2A2E6519-A2B8-4A6B-8849-4873578D7C8C} = {195014EB-9F92-4638-B88F-B20B380BCA9F} {E550D725-9C80-4242-8A3F-C1A3E020DEA2} = {195014EB-9F92-4638-B88F-B20B380BCA9F} {1C0017D8-35B5-4CA0-8FC7-A83F46DBDC99} = {2A2E6519-A2B8-4A6B-8849-4873578D7C8C} Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Helpers/SuspendDataGridViewColumnResizes.cs =================================================================== diff -u -r766487194eab00bc9205f5cd29f269c9af5f2ab8 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/Common/src/Ringtoets.Common.Forms/Helpers/SuspendDataGridViewColumnResizes.cs (.../SuspendDataGridViewColumnResizes.cs) (revision 766487194eab00bc9205f5cd29f269c9af5f2ab8) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Helpers/SuspendDataGridViewColumnResizes.cs (.../SuspendDataGridViewColumnResizes.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -17,6 +17,10 @@ private readonly DataGridViewColumn column; private readonly DataGridViewAutoSizeColumnMode originalValue; + /// + /// Creates a new instance of . + /// + /// The column to suspend. public SuspendDataGridViewColumnResizes(DataGridViewColumn columnToSuspend) { column = columnToSuspend; Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenarioRow.cs =================================================================== diff -u -r766487194eab00bc9205f5cd29f269c9af5f2ab8 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenarioRow.cs (.../GrassCoverErosionInwardsScenarioRow.cs) (revision 766487194eab00bc9205f5cd29f269c9af5f2ab8) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenarioRow.cs (.../GrassCoverErosionInwardsScenarioRow.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -38,6 +38,7 @@ /// Initializes a new instance of the class. /// /// The section result. + /// Thrown when is null. public GrassCoverErosionInwardsScenarioRow(GrassCoverErosionInwardsFailureMechanismSectionResult sectionResult) { if (sectionResult == null) Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenariosView.cs =================================================================== diff -u -re5658f822fa85cab8e99cb3069867d3a87867386 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenariosView.cs (.../GrassCoverErosionInwardsScenariosView.cs) (revision e5658f822fa85cab8e99cb3069867d3a87867386) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenariosView.cs (.../GrassCoverErosionInwardsScenariosView.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -120,8 +120,6 @@ base.Dispose(disposing); } - //private DataGridViewControl DataGridViewControl { get; set; } - private void AddDataGridColumns() { dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(sr => sr.Name), @@ -150,9 +148,8 @@ using (new SuspendDataGridViewColumnResizes(dataGridViewControl.GetColumnFromIndex(calculationsColumnIndex))) { var columnItems = ((DataGridViewComboBoxColumn) dataGridViewControl.GetColumnFromIndex(calculationsColumnIndex)).Items; - columnItems.Clear(); var items = data.GetCalculations().OfType().Select(c => new DataGridViewComboBoxItemWrapper(c)); - columnItems.AddRange(items.Cast().ToArray()); + SetItemsOnObjectCollection(columnItems, items.Cast().ToArray()); } dataGridViewControl.SetDataSource(FailureMechanism.SectionResults.Select(sectionResult => new GrassCoverErosionInwardsScenarioRow(sectionResult)).ToList()); @@ -189,9 +186,13 @@ } var cell = (DataGridViewComboBoxCell) dataGridViewRow.Cells[calculationsColumnIndex]; + SetItemsOnObjectCollection(cell.Items, items.Cast().ToArray()); + } - cell.Items.Clear(); - cell.Items.AddRange(items.Cast().ToArray()); + private static void SetItemsOnObjectCollection(DataGridViewComboBoxCell.ObjectCollection objectCollection, object[] comboBoxItems) + { + objectCollection.Clear(); + objectCollection.AddRange(comboBoxItems); } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs =================================================================== diff -u -raf42240385db3d3f04bca830513c7464e6f74668 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs (.../GrassCoverErosionInwardsGuiPlugin.cs) (revision af42240385db3d3f04bca830513c7464e6f74668) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs (.../GrassCoverErosionInwardsGuiPlugin.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -200,26 +200,6 @@ EmptyProbabilityAssessmentOutputContextMenuStrip); } - private static bool CloseScenariosViewForData(GrassCoverErosionInwardsScenariosView view, object removedData) - { - var assessmentSection = removedData as IAssessmentSection; - if (assessmentSection != null) - { - return assessmentSection.GetFailureMechanisms() - .OfType() - .Any(fm => ReferenceEquals(view.Data, fm.CalculationsGroup)); - } - - var coverErosionInwardsFailureMechanism = removedData as GrassCoverErosionInwardsFailureMechanism; - if (coverErosionInwardsFailureMechanism != null) - { - return ReferenceEquals(view.Data, coverErosionInwardsFailureMechanism.CalculationsGroup); - } - - var coverErosionInwardsFailureMechanismContext = removedData as GrassCoverErosionInwardsFailureMechanismContext; - return coverErosionInwardsFailureMechanismContext != null && ReferenceEquals(view.Data, coverErosionInwardsFailureMechanismContext.WrappedData.CalculationsGroup); - } - private void CalculateAll(GrassCoverErosionInwardsFailureMechanism failureMechanism, IEnumerable calculations, IAssessmentSection assessmentSection) { ActivityProgressDialogRunner.Run(Gui.MainWindow, calculations.Select(calc => new GrassCoverErosionInwardsCalculationActivity(calc, @@ -249,6 +229,31 @@ return null; } + #region GrassCoverErosionInwardsScenariosView ViewInfo + + private static bool CloseScenariosViewForData(GrassCoverErosionInwardsScenariosView view, object removedData) + { + var failureMechanism = removedData as GrassCoverErosionInwardsFailureMechanism; + + var failureMechanismContext = removedData as GrassCoverErosionInwardsFailureMechanismContext; + if (failureMechanismContext != null) + { + failureMechanism = failureMechanismContext.WrappedData; + } + + var assessmentSection = removedData as IAssessmentSection; + if (assessmentSection != null) + { + failureMechanism = assessmentSection.GetFailureMechanisms() + .OfType() + .FirstOrDefault(); + } + + return failureMechanism != null && ReferenceEquals(view.Data, failureMechanism.CalculationsGroup); + } + + #endregion + #region GrassCoverErosionInwardsFailureMechanismResultView ViewInfo private static bool CloseFailureMechanismResultViewForData(GrassCoverErosionInwardsFailureMechanismResultView view, object o) Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationActivity.cs =================================================================== diff -u -re5658f822fa85cab8e99cb3069867d3a87867386 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationActivity.cs (.../GrassCoverErosionInwardsCalculationActivity.cs) (revision e5658f822fa85cab8e99cb3069867d3a87867386) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationActivity.cs (.../GrassCoverErosionInwardsCalculationActivity.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Core.Common.Base.Service; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; @@ -46,9 +47,27 @@ /// The directory of the HLCD file that should be used for performing the calculation. /// The failure mechanism the calculation belongs to. /// The assessment section the calculation belongs to. + /// Thrown when any input argument is null. public GrassCoverErosionInwardsCalculationActivity(GrassCoverErosionInwardsCalculation calculation, string hlcdDirectory, GrassCoverErosionInwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { + if (calculation == null) + { + throw new ArgumentNullException("calculation"); + } + if (hlcdDirectory == null) + { + throw new ArgumentNullException("hlcdDirectory"); + } + if (failureMechanism == null) + { + throw new ArgumentNullException("failureMechanism"); + } + if (assessmentSection == null) + { + throw new ArgumentNullException("assessmentSection"); + } + this.calculation = calculation; this.hlcdDirectory = hlcdDirectory; this.failureMechanism = failureMechanism; Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Utils/AssignUnAssignCalculations.cs =================================================================== diff -u -re5658f822fa85cab8e99cb3069867d3a87867386 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Utils/AssignUnAssignCalculations.cs (.../AssignUnAssignCalculations.cs) (revision e5658f822fa85cab8e99cb3069867d3a87867386) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Utils/AssignUnAssignCalculations.cs (.../AssignUnAssignCalculations.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.Linq; using Ringtoets.Common.Data.FailureMechanism; @@ -38,8 +39,18 @@ /// The containing the /// objects. /// The . + /// When any input parameter is null. public static void Update(GrassCoverErosionInwardsFailureMechanism failureMechanism, GrassCoverErosionInwardsCalculation calculation) { + if (failureMechanism == null) + { + throw new ArgumentNullException("failureMechanism"); + } + if (calculation == null) + { + throw new ArgumentNullException("calculation"); + } + // The FailureMechanismSection which contains the calculation whose dikeprofile has been updated. FailureMechanismSection failureMechanismSection = GrassCoverErosionInwardsHelper.FailureMechanismSectionForCalculation(failureMechanism.SectionResults, calculation); Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Utils/GrassCoverErosionInwardsHelper.cs =================================================================== diff -u -re5658f822fa85cab8e99cb3069867d3a87867386 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Utils/GrassCoverErosionInwardsHelper.cs (.../GrassCoverErosionInwardsHelper.cs) (revision e5658f822fa85cab8e99cb3069867d3a87867386) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Utils/GrassCoverErosionInwardsHelper.cs (.../GrassCoverErosionInwardsHelper.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.Linq; using Core.Common.Base.Geometry; @@ -41,19 +42,25 @@ /// A containing a /// of objects /// for each section name which has calculations. + /// When any input parameter is null. public static Dictionary> CollectCalculationsPerSegment( IEnumerable sectionResults, IEnumerable calculations) { - var calculationsPerSegment = new Dictionary>(); + if (sectionResults == null) + { + throw new ArgumentNullException("sectionResults"); + } - if (sectionResults == null || calculations == null) + if (calculations == null) { - return calculationsPerSegment; + throw new ArgumentNullException("calculations"); } SectionSegments[] sectionSegments = MakeSectionSegments(sectionResults); + var calculationsPerSegment = new Dictionary>(); + foreach (var calculation in calculations) { FailureMechanismSection section = FindSectionForCalculation(sectionSegments, calculation); @@ -74,15 +81,21 @@ /// whose are considered. /// The . /// The containing , or null. + /// When any input parameter is null. public static FailureMechanismSection FailureMechanismSectionForCalculation( IEnumerable sectionResults, GrassCoverErosionInwardsCalculation calculation) { - if (sectionResults == null || calculation == null) + if (sectionResults == null) { - return null; + throw new ArgumentNullException("sectionResults"); } + if (calculation == null) + { + throw new ArgumentNullException("calculation"); + } + SectionSegments[] sectionSegments = MakeSectionSegments(sectionResults); return FindSectionForCalculation(sectionSegments, calculation); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj =================================================================== diff -u -re5658f822fa85cab8e99cb3069867d3a87867386 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision e5658f822fa85cab8e99cb3069867d3a87867386) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -103,7 +103,6 @@ - Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsScenarioRowTest.cs =================================================================== diff -u -r766487194eab00bc9205f5cd29f269c9af5f2ab8 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsScenarioRowTest.cs (.../GrassCoverErosionInwardsScenarioRowTest.cs) (revision 766487194eab00bc9205f5cd29f269c9af5f2ab8) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsScenarioRowTest.cs (.../GrassCoverErosionInwardsScenarioRowTest.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -38,7 +38,7 @@ public class GrassCoverErosionInwardsScenarioRowTest { [Test] - public void ParameteredConstructor_ValidValue_ExpectedValues() + public void ParameteredConstructor_ExpectedValues() { // Setup var section = new FailureMechanismSection("testName", new[] @@ -59,8 +59,6 @@ [Test] public void ParameterdConstructor_SectionResultIsNull_ThrowArgumentNullException() { - // Setup - // Call TestDelegate call = () => new GrassCoverErosionInwardsScenarioRow(null); @@ -90,6 +88,8 @@ // Assert Assert.AreSame(calculation, row.Calculation); Assert.AreSame(calculation, sectionResult.Calculation); + + } [Test] Fisheye: Tag d207738be4ce6f50f4e3e00839ea433acea10bbd refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsViewHelperTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsScenariosViewIntegrationTest.cs =================================================================== diff -u -r766487194eab00bc9205f5cd29f269c9af5f2ab8 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsScenariosViewIntegrationTest.cs (.../GrassCoverErosionInwardsScenariosViewIntegrationTest.cs) (revision 766487194eab00bc9205f5cd29f269c9af5f2ab8) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsScenariosViewIntegrationTest.cs (.../GrassCoverErosionInwardsScenariosViewIntegrationTest.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -87,9 +87,10 @@ IntegrationTestHelper.ImportReferenceLine(assessmentSection); IntegrationTestHelper.ImportFailureMechanismSections(assessmentSection, assessmentSection.GrassCoverErosionInwards); + CalculationGroup calculationsGroup = assessmentSection.GrassCoverErosionInwards.CalculationsGroup; var view = new GrassCoverErosionInwardsScenariosView() { - Data = assessmentSection.GrassCoverErosionInwards.CalculationsGroup, + Data = calculationsGroup, FailureMechanism = assessmentSection.GrassCoverErosionInwards }; form.Controls.Add(view); @@ -104,7 +105,7 @@ // Call foreach (var profile in assessmentSection.GrassCoverErosionInwards.DikeProfiles) { - assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation + calculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation { Name = NamingHelper.GetUniqueName(((CalculationGroup) view.Data).Children, profile.Name, c => c.Name), InputParameters = @@ -113,12 +114,13 @@ } }); } - assessmentSection.GrassCoverErosionInwards.CalculationsGroup.NotifyObservers(); + calculationsGroup.NotifyObservers(); // Assert - Assert.AreEqual(2, ((DataGridViewComboBoxCell) dataGridView.Rows[13].Cells[1]).Items.Count); - Assert.AreEqual("", ((DataGridViewComboBoxCell) dataGridView.Rows[13].Cells[1]).Items[0].ToString()); - Assert.AreEqual("profiel63p1ID", ((DataGridViewComboBoxCell) dataGridView.Rows[13].Cells[1]).Items[1].ToString()); + DataGridViewCell dataGridViewCell = dataGridView.Rows[13].Cells[1]; + Assert.AreEqual(2, ((DataGridViewComboBoxCell) dataGridViewCell).Items.Count); + Assert.AreEqual("", ((DataGridViewComboBoxCell) dataGridViewCell).Items[0].ToString()); + Assert.AreEqual("profiel63p1ID", ((DataGridViewComboBoxCell) dataGridViewCell).Items[1].ToString()); } } @@ -132,9 +134,10 @@ IntegrationTestHelper.ImportReferenceLine(assessmentSection); IntegrationTestHelper.ImportFailureMechanismSections(assessmentSection, assessmentSection.GrassCoverErosionInwards); + CalculationGroup calculationsGroup = assessmentSection.GrassCoverErosionInwards.CalculationsGroup; var view = new GrassCoverErosionInwardsScenariosView() { - Data = assessmentSection.GrassCoverErosionInwards.CalculationsGroup, + Data = calculationsGroup, FailureMechanism = assessmentSection.GrassCoverErosionInwards }; form.Controls.Add(view); @@ -148,28 +151,29 @@ foreach (var profile in assessmentSection.GrassCoverErosionInwards.DikeProfiles) { - assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation + calculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation { - Name = NamingHelper.GetUniqueName(assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children, profile.Name, c => c.Name), + Name = NamingHelper.GetUniqueName(calculationsGroup.Children, profile.Name, c => c.Name), InputParameters = { DikeProfile = profile } }); } - assessmentSection.GrassCoverErosionInwards.CalculationsGroup.NotifyObservers(); + calculationsGroup.NotifyObservers(); // Call - foreach (var calculationBase in assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children) + foreach (var calculationBase in calculationsGroup.Children) { var calculation = (GrassCoverErosionInwardsCalculation) calculationBase; calculation.Name += "_changed"; } // Assert - Assert.AreEqual(2, ((DataGridViewComboBoxCell) dataGridView.Rows[13].Cells[1]).Items.Count); - Assert.AreEqual("", ((DataGridViewComboBoxCell) dataGridView.Rows[13].Cells[1]).Items[0].ToString()); - Assert.AreEqual("profiel63p1ID_changed", ((DataGridViewComboBoxCell) dataGridView.Rows[13].Cells[1]).Items[1].ToString()); + DataGridViewCell dataGridViewCell = dataGridView.Rows[13].Cells[1]; + Assert.AreEqual(2, ((DataGridViewComboBoxCell) dataGridViewCell).Items.Count); + Assert.AreEqual("", ((DataGridViewComboBoxCell) dataGridViewCell).Items[0].ToString()); + Assert.AreEqual("profiel63p1ID_changed", ((DataGridViewComboBoxCell) dataGridViewCell).Items[1].ToString()); } } @@ -216,10 +220,11 @@ calculationsGroup.NotifyObservers(); // Assert - Assert.AreEqual(3, ((DataGridViewComboBoxCell) dataGridView.Rows[13].Cells[1]).Items.Count); - Assert.AreEqual("", ((DataGridViewComboBoxCell) dataGridView.Rows[13].Cells[1]).Items[0].ToString()); - Assert.AreEqual("profiel63p1ID", ((DataGridViewComboBoxCell) dataGridView.Rows[13].Cells[1]).Items[1].ToString()); - Assert.AreEqual("profiel63p2ID", ((DataGridViewComboBoxCell) dataGridView.Rows[13].Cells[1]).Items[2].ToString()); + DataGridViewCell dataGridViewCell = dataGridView.Rows[13].Cells[1]; + Assert.AreEqual(3, ((DataGridViewComboBoxCell) dataGridViewCell).Items.Count); + Assert.AreEqual("", ((DataGridViewComboBoxCell) dataGridViewCell).Items[0].ToString()); + Assert.AreEqual("profiel63p1ID", ((DataGridViewComboBoxCell) dataGridViewCell).Items[1].ToString()); + Assert.AreEqual("profiel63p2ID", ((DataGridViewComboBoxCell) dataGridViewCell).Items[2].ToString()); } } } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Utils.Test/GrassCoverErosionInwardsHelperTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Utils.Test/GrassCoverErosionInwardsHelperTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Utils.Test/GrassCoverErosionInwardsHelperTest.cs (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -0,0 +1,255 @@ +// 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.Collections.Generic; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.GrassCoverErosionInwards.Data; + +namespace Ringtoets.GrassCoverErosionInwards.Utils.Test +{ + [TestFixture] + public class GrassCoverErosionInwardsHelperTest + { + [Test] + public void CollectCalculationsPerSegment_SectionResultsAndCalculationsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionInwardsHelper.CollectCalculationsPerSegment(null, null); + + // Assert + Assert.Throws(call); + } + + [Test] + public void CollectCalculationsPerSegment_SectionResultsNull_ThrowsArgumentNullException() + { + // Setup + var calculations = new GrassCoverErosionInwardsCalculation[0]; + + // Call + TestDelegate call = () => GrassCoverErosionInwardsHelper.CollectCalculationsPerSegment(null, calculations); + + // Assert + var paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("sectionResults", paramName); + } + + [Test] + public void CollectCalculationsPerSegment_CalculationsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionInwardsHelper.CollectCalculationsPerSegment(oneSectionResult, null); + + // Assert + var paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("calculations", paramName); + } + + [Test] + public void CollectCalculationsPerSegment_ValidEmptyData_EmptyDictionary() + { + // Setup + var calculations = new GrassCoverErosionInwardsCalculation[0]; + + // Call + var collectCalculationsPerSegment = GrassCoverErosionInwardsHelper.CollectCalculationsPerSegment(oneSectionResult, calculations); + + // Assert + Assert.AreEqual(0, collectCalculationsPerSegment.Count); + } + + [Test] + public void CollectCalculationsPerSegment_MultipleCalculationsInSegment_OneSegmentHasAllCalculations() + { + // Setup + var calculations = new[] + { + new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = new DikeProfile(new Point2D(1.1, 2.2), new RoughnessPoint[0], new Point2D[0]) + } + }, + new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = new DikeProfile(new Point2D(3.3, 4.4), new RoughnessPoint[0], new Point2D[0]) + } + } + }; + + // Call + var collectCalculationsPerSegment = GrassCoverErosionInwardsHelper.CollectCalculationsPerSegment(twoSectionResults, calculations); + + // Assert + Assert.AreEqual(1, collectCalculationsPerSegment.Count); + Assert.IsTrue(collectCalculationsPerSegment.ContainsKey("firstSection")); + Assert.AreEqual(2, collectCalculationsPerSegment["firstSection"].Count); + } + + [Test] + public void CollectCalculationsPerSegment_SingleCalculationPerSegment_OneCalculationPerSegment() + { + // Setup + var calculations = new[] + { + new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = new DikeProfile(new Point2D(1.1, 2.2), new RoughnessPoint[0], new Point2D[0]) + } + }, + new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = new DikeProfile(new Point2D(50.0, 66.0), new RoughnessPoint[0], new Point2D[0]) + } + } + }; + + // Call + var collectCalculationsPerSegment = GrassCoverErosionInwardsHelper.CollectCalculationsPerSegment(twoSectionResults, calculations); + + // Assert + Assert.AreEqual(2, collectCalculationsPerSegment.Count); + Assert.AreEqual(1, collectCalculationsPerSegment["firstSection"].Count); + Assert.AreEqual(1, collectCalculationsPerSegment["secondSection"].Count); + } + + [Test] + public void FailureMechanismSectionForCalculation_SectionResultAndCalculationNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionInwardsHelper.FailureMechanismSectionForCalculation(null, null); + + // Assert + Assert.Throws(call); + } + + [Test] + public void FailureMechanismSectionForCalculation_SectionResultsNull_ThrowsArgumentNullException() + { + // Setup + var calculation = new GrassCoverErosionInwardsCalculation(); + + // Call + TestDelegate call = () => GrassCoverErosionInwardsHelper.FailureMechanismSectionForCalculation(null, calculation); + + // Assert + var paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("sectionResults", paramName); + } + + [Test] + public void FailureMechanismSectionForCalculation_CalculationNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionInwardsHelper.FailureMechanismSectionForCalculation(oneSectionResult, null); + + // Assert + var paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("calculation", paramName); + } + + [Test] + public void FailureMechanismSectionForCalculation_SectionResultsEmpty_ReturnsNull() + { + // Setup + var calculation = new GrassCoverErosionInwardsCalculation(); + + // Call + var failureMechanismSection = GrassCoverErosionInwardsHelper.FailureMechanismSectionForCalculation(oneSectionResult, calculation); + + // Assert + Assert.IsNull(failureMechanismSection); + } + + [Test] + public void FailureMechanismSectionForCalculation_FirstSectionResultContainsCalculation_FailureMechanismSectionOfFirstSectionResult() + { + // Setup + var calculation = new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = new DikeProfile(new Point2D(1.1, 2.2), new RoughnessPoint[0], new Point2D[0]) + } + }; + + // Call + var failureMechanismSection = GrassCoverErosionInwardsHelper.FailureMechanismSectionForCalculation(twoSectionResults, calculation); + + // Assert + Assert.AreSame(twoSectionResults[0].Section, failureMechanismSection); + } + + [Test] + public void FailureMechanismSectionForCalculation_SecondSectionResultContainsCalculation_FailureMechanismSectionOfSecondSectionResult() + { + // Setup + var calculation = new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = new DikeProfile(new Point2D(50.0, 66.0), new RoughnessPoint[0], new Point2D[0]) + } + }; + + // Call + var failureMechanismSection = GrassCoverErosionInwardsHelper.FailureMechanismSectionForCalculation(twoSectionResults, calculation); + + // Assert + Assert.AreSame(twoSectionResults[1].Section, failureMechanismSection); + } + + private readonly GrassCoverErosionInwardsFailureMechanismSectionResult[] oneSectionResult = new[] + { + new GrassCoverErosionInwardsFailureMechanismSectionResult( + new FailureMechanismSection("testFailureMechanismSection", new List + { + new Point2D(0.0, 0.0) + })) + }; + + private readonly GrassCoverErosionInwardsFailureMechanismSectionResult[] twoSectionResults = new[] + { + new GrassCoverErosionInwardsFailureMechanismSectionResult( + new FailureMechanismSection("firstSection", new List + { + new Point2D(0.0, 0.0), + new Point2D(10.0, 10.0), + })), + new GrassCoverErosionInwardsFailureMechanismSectionResult( + new FailureMechanismSection("secondSection", new List + { + new Point2D(11.0, 11.0), + new Point2D(100.0, 100.0), + })) + }; + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Utils.Test/Properties/AssemblyInfo.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Utils.Test/Properties/AssemblyInfo.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Utils.Test/Properties/AssemblyInfo.cs (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -0,0 +1,28 @@ +// 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.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Ringtoets.GrassCoverErosionInwards.Utils.Test")] +[assembly: AssemblyProduct("Ringtoets.GrassCoverErosionInwards.Utils.Test")] +[assembly: ComVisible(false)] +[assembly: Guid("67148a17-f4ef-4ccd-9b7a-3a7312d24271")] \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Utils.Test/Ringtoets.GrassCoverErosionInwards.Utils.Test.csproj =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Utils.Test/Ringtoets.GrassCoverErosionInwards.Utils.Test.csproj (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Utils.Test/Ringtoets.GrassCoverErosionInwards.Utils.Test.csproj (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -0,0 +1,84 @@ + + + + Debug + x86 + {5C19638A-3CC5-496F-8552-385785E728E3} + Library + Properties + Ringtoets.GrassCoverErosionInwards.Utils.Test + Ringtoets.GrassCoverErosionInwards.Utils.Test + v4.0 + 512 + + + true + bin\Debug\ + 4 + x86 + MinimumRecommendedRules.ruleset + TRACE;DEBUG + full + + + none + bin\Release\ + 4 + x86 + MinimumRecommendedRules.ruleset + TRACE + true + + + bin\ReleaseForCodeCoverage\ + TRACE + true + x86 + MinimumRecommendedRules.ruleset + pdbonly + + + + ..\..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll + True + + + + + + + + + + + Copying.licenseheader + + + + + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + + + {D4200F43-3F72-4F42-AF0A-8CED416A38EC} + Ringtoets.Common.Data + + + {90DE728E-48EF-4665-AB38-3D88E41D9F4D} + Ringtoets.GrassCoverErosionInwards.Data + + + {99573570-EE00-4264-8147-26A1B25DB23F} + Ringtoets.GrassCoverErosionInwards.Utils + + + + + \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Utils.Test/packages.config =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Utils.Test/packages.config (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Utils.Test/packages.config (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -0,0 +1,4 @@ + + + + \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationActivity.cs =================================================================== diff -u -r6ccc539ce58e63f0e0fbff0da189c87b65146129 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationActivity.cs (.../HeightStructuresCalculationActivity.cs) (revision 6ccc539ce58e63f0e0fbff0da189c87b65146129) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationActivity.cs (.../HeightStructuresCalculationActivity.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Linq; using Core.Common.Base.Service; using Ringtoets.Common.Data.AssessmentSection; @@ -54,9 +55,27 @@ /// The directory of the HLCD file that should be used for performing the calculation. /// The failure mechanism the calculation belongs to. /// The assessment section the calculation belongs to. + /// Thrown when any input argument is null. public HeightStructuresCalculationActivity(HeightStructuresCalculation calculation, string hlcdDirectory, HeightStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { + if (calculation == null) + { + throw new ArgumentNullException("calculation"); + } + if (hlcdDirectory == null) + { + throw new ArgumentNullException("hlcdDirectory"); + } + if (failureMechanism == null) + { + throw new ArgumentNullException("failureMechanism"); + } + if (assessmentSection == null) + { + throw new ArgumentNullException("assessmentSection"); + } + this.calculation = calculation; this.hlcdDirectory = hlcdDirectory; this.failureMechanism = failureMechanism; Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/DesignWaterLevelCalculationActivity.cs =================================================================== diff -u -rc45538da49b7940b722e1f12b95d16beb4ee8206 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/Integration/src/Ringtoets.Integration.Service/DesignWaterLevelCalculationActivity.cs (.../DesignWaterLevelCalculationActivity.cs) (revision c45538da49b7940b722e1f12b95d16beb4ee8206) +++ Ringtoets/Integration/src/Ringtoets.Integration.Service/DesignWaterLevelCalculationActivity.cs (.../DesignWaterLevelCalculationActivity.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Core.Common.Base.Service; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.HydraRing.Calculation.Activities; @@ -49,8 +50,18 @@ /// /// The data which is used for the calculation. /// The to perform the calculation for. + /// Thrown when any input argument is null. public DesignWaterLevelCalculationActivity(IAssessmentSection assessmentSection, HydraulicBoundaryLocation hydraulicBoundaryLocation) { + if (assessmentSection == null) + { + throw new ArgumentNullException("assessmentSection"); + } + if (hydraulicBoundaryLocation == null) + { + throw new ArgumentNullException("hydraulicBoundaryLocation"); + } + this.assessmentSection = assessmentSection; this.hydraulicBoundaryLocation = hydraulicBoundaryLocation; } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs =================================================================== diff -u -r766487194eab00bc9205f5cd29f269c9af5f2ab8 -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision 766487194eab00bc9205f5cd29f269c9af5f2ab8) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -340,10 +340,6 @@ objectCollection.AddRange(comboBoxItems); } - #region Nested types - - #endregion - #region Data sources private void UpdateDataGridViewDataSource() Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationActivity.cs =================================================================== diff -u -rbb0aeecc47206f5089ab04ca6c3575a1de8c206f -rd207738be4ce6f50f4e3e00839ea433acea10bbd --- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationActivity.cs (.../PipingCalculationActivity.cs) (revision bb0aeecc47206f5089ab04ca6c3575a1de8c206f) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationActivity.cs (.../PipingCalculationActivity.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Core.Common.Base.Service; using Ringtoets.Piping.Data; @@ -43,8 +44,18 @@ /// The return period to assess for. /// The contribution of piping as a percentage (0-100) to the total of the failure probability /// of the assessment section. + /// Thrown when any input argument is null. public PipingCalculationActivity(PipingCalculation calculation, PipingProbabilityAssessmentInput pipingProbabilityAssessmentInput, int norm, double contribution) { + if (calculation == null) + { + throw new ArgumentNullException("calculation"); + } + if (pipingProbabilityAssessmentInput == null) + { + throw new ArgumentNullException("pipingProbabilityAssessmentInput"); + } + this.calculation = calculation; this.pipingProbabilityAssessmentInput = pipingProbabilityAssessmentInput; this.norm = norm;