Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Builders/FailureMechanismSectionResultColumnBuilder.cs =================================================================== diff -u -ra0cc5b43d22f89e997877215a505f6fab58aa70b -ree067be0b11728670314dd61f2dd885fd69f82ea --- Ringtoets/Common/src/Ringtoets.Common.Forms/Builders/FailureMechanismSectionResultColumnBuilder.cs (.../FailureMechanismSectionResultColumnBuilder.cs) (revision a0cc5b43d22f89e997877215a505f6fab58aa70b) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Builders/FailureMechanismSectionResultColumnBuilder.cs (.../FailureMechanismSectionResultColumnBuilder.cs) (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Linq; using Core.Common.Controls.DataGrid; using Core.Common.Util; @@ -52,18 +53,128 @@ throw new ArgumentNullException(nameof(dataPropertyName)); } - EnumDisplayWrapper[] simpleAssessmentDataSource = - Enum.GetValues(typeof(SimpleAssessmentResultType)) - .OfType() - .Select(sa => new EnumDisplayWrapper(sa)) - .ToArray(); + IEnumerable> dataSource = CreateEnumDisplayWrappers(); dataGridViewControl.AddComboBoxColumn( dataPropertyName, Resources.FailureMechanismResultView_SimpleAssessmentResult_DisplayName, - simpleAssessmentDataSource, + dataSource, nameof(EnumDisplayWrapper.Value), nameof(EnumDisplayWrapper.DisplayName)); } + + /// + /// Adds a column to the showing a + /// . + /// + /// The to add the column to. + /// The data property name of the column. + /// Thrown when any parameter is null. + public static void AddDetailedAssessmentResultColumn(DataGridViewControl dataGridViewControl, string dataPropertyName) + { + if (dataGridViewControl == null) + { + throw new ArgumentNullException(nameof(dataGridViewControl)); + } + + if (dataPropertyName == null) + { + throw new ArgumentNullException(nameof(dataPropertyName)); + } + + IEnumerable> dataSource = CreateEnumDisplayWrappers(); + + dataGridViewControl.AddComboBoxColumn( + dataPropertyName, + Resources.FailureMechanismResultView_DetailedAssessment_DisplayName, + dataSource, + nameof(EnumDisplayWrapper.Value), + nameof(EnumDisplayWrapper.DisplayName)); + } + + /// + /// Adds a column to the showing the detailed + /// assessment probability. + /// + /// The to add the column to. + /// The data property name of the column. + /// Thrown when any parameter is null. + public static void AddDetailedAssessmentProbabilityColumn(DataGridViewControl dataGridViewControl, string dataPropertyName) + { + if (dataGridViewControl == null) + { + throw new ArgumentNullException(nameof(dataGridViewControl)); + } + + if (dataPropertyName == null) + { + throw new ArgumentNullException(nameof(dataPropertyName)); + } + + dataGridViewControl.AddTextBoxColumn( + dataPropertyName, + Resources.FailureMechanismResultView_DetailedAssessmentProbability_DisplayName); + } + + /// + /// Adds a column to the showing a + /// . + /// + /// The to add the column to. + /// The data property name of the column. + /// Thrown when any parameter is null. + public static void AddTailorMadeAssessmentResultColumn(DataGridViewControl dataGridViewControl, string dataPropertyName) + { + if (dataGridViewControl == null) + { + throw new ArgumentNullException(nameof(dataGridViewControl)); + } + + if (dataPropertyName == null) + { + throw new ArgumentNullException(nameof(dataPropertyName)); + } + + IEnumerable> dataSource = CreateEnumDisplayWrappers(); + + dataGridViewControl.AddComboBoxColumn( + dataPropertyName, + Resources.FailureMechanismResultView_TailorMadeAssessment_DisplayName, + dataSource, + nameof(EnumDisplayWrapper.Value), + nameof(EnumDisplayWrapper.DisplayName)); + } + + /// + /// Adds a column to the showing the tailor made + /// assessment probability. + /// + /// The to add the column to. + /// The data property name of the column. + /// Thrown when any parameter is null. + public static void AddTailorMadeAssessmentProbabilityColumn(DataGridViewControl dataGridViewControl, string dataPropertyName) + { + if (dataGridViewControl == null) + { + throw new ArgumentNullException(nameof(dataGridViewControl)); + } + + if (dataPropertyName == null) + { + throw new ArgumentNullException(nameof(dataPropertyName)); + } + + dataGridViewControl.AddTextBoxColumn( + dataPropertyName, + Resources.FailureMechanismResultView_TailorMadeAssessmentProbability_DisplayName); + } + + private static IEnumerable> CreateEnumDisplayWrappers() + { + return Enum.GetValues(typeof(T)) + .OfType() + .Select(e => new EnumDisplayWrapper(e)) + .ToArray(); + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -rba2c38d1315dda29a2bd0005138530b2aeb10f1f -ree067be0b11728670314dd61f2dd885fd69f82ea --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ba2c38d1315dda29a2bd0005138530b2aeb10f1f) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -1445,6 +1445,16 @@ } /// + /// Looks up a localized string similar to Gedetailleerde toets per vak + ///Faalkans. + /// + public static string FailureMechanismResultView_DetailedAssessmentProbability_DisplayName { + get { + return ResourceManager.GetString("FailureMechanismResultView_DetailedAssessmentProbability_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Eenvoudige toets. /// public static string FailureMechanismResultView_SimpleAssessmentResult_DisplayName { @@ -1463,6 +1473,16 @@ } /// + /// Looks up a localized string similar to Toets op maat + ///Faalkans. + /// + public static string FailureMechanismResultView_TailorMadeAssessmentProbability_DisplayName { + get { + return ResourceManager.GetString("FailureMechanismResultView_TailorMadeAssessmentProbability_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Eindpunt van het vak (X-coördinaat, Y-coördinaat).. /// public static string FailureMechanismSection_EndPoint_Description { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx =================================================================== diff -u -rba2c38d1315dda29a2bd0005138530b2aeb10f1f -ree067be0b11728670314dd61f2dd885fd69f82ea --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision ba2c38d1315dda29a2bd0005138530b2aeb10f1f) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -223,9 +223,17 @@ Toets op maat + + Toets op maat +Faalkans + Gedetailleerde toets per vak + + Gedetailleerde toets per vak +Faalkans + Vak Index: Ringtoets/Common/src/Ringtoets.Common.Primitives/DetailedAssessmentResultType.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Primitives/DetailedAssessmentResultType.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Primitives/DetailedAssessmentResultType.cs (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -0,0 +1,48 @@ +// Copyright (C) Stichting Deltares 2017. 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 Core.Common.Util.Attributes; +using Ringtoets.Common.Primitives.Properties; + +namespace Ringtoets.Common.Primitives +{ + /// + /// This enum defines the possible result types for a detailed assessment + /// on a failure mechanism section. + /// + public enum DetailedAssessmentResultType + { + /// + /// The calculated probability for this failure + /// mechanism section has to be entered. + /// + [ResourcesDisplayName(typeof(Resources), nameof(Resources.AssessmentResultType_Probability))] + Probability = 1, + + /// + /// No assessment has been performed for this failure + /// mechanism section. + /// + [ResourcesDisplayName(typeof(Resources), nameof(Resources.AssessmentResultType_NotAssessed))] + NotAssessed = 2 + + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Primitives/Properties/Resources.Designer.cs =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -ree067be0b11728670314dd61f2dd885fd69f82ea --- Ringtoets/Common/src/Ringtoets.Common.Primitives/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/Common/src/Ringtoets.Common.Primitives/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -82,24 +82,42 @@ } /// - /// Looks up a localized string similar to VB. + /// Looks up a localized string similar to <selecteer>. /// - internal static string SimpleAssessmentResultType_AssessFurther { + internal static string AssessmentResultType_None { get { - return ResourceManager.GetString("SimpleAssessmentResultType_AssessFurther", resourceCulture); + return ResourceManager.GetString("AssessmentResultType_None", resourceCulture); } } /// - /// Looks up a localized string similar to <selecteer>. + /// Looks up a localized string similar to NGO. /// - internal static string SimpleAssessmentResultType_None { + internal static string AssessmentResultType_NotAssessed { get { - return ResourceManager.GetString("SimpleAssessmentResultType_None", resourceCulture); + return ResourceManager.GetString("AssessmentResultType_NotAssessed", resourceCulture); } } /// + /// Looks up a localized string similar to Faalkans. + /// + internal static string AssessmentResultType_Probability { + get { + return ResourceManager.GetString("AssessmentResultType_Probability", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to VB. + /// + internal static string SimpleAssessmentResultType_AssessFurther { + get { + return ResourceManager.GetString("SimpleAssessmentResultType_AssessFurther", resourceCulture); + } + } + + /// /// Looks up a localized string similar to NVT. /// internal static string SimpleAssessmentResultType_NotApplicable { @@ -125,5 +143,23 @@ return ResourceManager.GetString("SimpleAssessmentResultValidityOnlyType_Applicable", resourceCulture); } } + + /// + /// Looks up a localized string similar to VN. + /// + internal static string TailorMadeAssessmentResultType_Insufficient { + get { + return ResourceManager.GetString("TailorMadeAssessmentResultType_Insufficient", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to V. + /// + internal static string TailorMadeAssessmentResultType_Sufficient { + get { + return ResourceManager.GetString("TailorMadeAssessmentResultType_Sufficient", resourceCulture); + } + } } } Index: Ringtoets/Common/src/Ringtoets.Common.Primitives/Properties/Resources.resx =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -ree067be0b11728670314dd61f2dd885fd69f82ea --- Ringtoets/Common/src/Ringtoets.Common.Primitives/Properties/Resources.resx (.../Resources.resx) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/Common/src/Ringtoets.Common.Primitives/Properties/Resources.resx (.../Resources.resx) (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -117,10 +117,16 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + NGO + + + Faalkans + VB - + <selecteer> @@ -132,4 +138,10 @@ WVT + + VN + + + V + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Primitives/Ringtoets.Common.Primitives.csproj =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -ree067be0b11728670314dd61f2dd885fd69f82ea --- Ringtoets/Common/src/Ringtoets.Common.Primitives/Ringtoets.Common.Primitives.csproj (.../Ringtoets.Common.Primitives.csproj) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/Common/src/Ringtoets.Common.Primitives/Ringtoets.Common.Primitives.csproj (.../Ringtoets.Common.Primitives.csproj) (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -11,12 +11,14 @@ + True True Resources.resx + Index: Ringtoets/Common/src/Ringtoets.Common.Primitives/SimpleAssessmentResultType.cs =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -ree067be0b11728670314dd61f2dd885fd69f82ea --- Ringtoets/Common/src/Ringtoets.Common.Primitives/SimpleAssessmentResultType.cs (.../SimpleAssessmentResultType.cs) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/Common/src/Ringtoets.Common.Primitives/SimpleAssessmentResultType.cs (.../SimpleAssessmentResultType.cs) (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -34,7 +34,7 @@ /// No option has been selected for this failure /// mechanism section. /// - [ResourcesDisplayName(typeof(Resources), nameof(Resources.SimpleAssessmentResultType_None))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.AssessmentResultType_None))] None = 1, /// Index: Ringtoets/Common/src/Ringtoets.Common.Primitives/SimpleAssessmentResultValidityOnlyType.cs =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -ree067be0b11728670314dd61f2dd885fd69f82ea --- Ringtoets/Common/src/Ringtoets.Common.Primitives/SimpleAssessmentResultValidityOnlyType.cs (.../SimpleAssessmentResultValidityOnlyType.cs) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/Common/src/Ringtoets.Common.Primitives/SimpleAssessmentResultValidityOnlyType.cs (.../SimpleAssessmentResultValidityOnlyType.cs) (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -34,7 +34,7 @@ /// No option has been selected for this failure /// mechanism section. /// - [ResourcesDisplayName(typeof(Resources), nameof(Resources.SimpleAssessmentResultType_None))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.AssessmentResultType_None))] None = 1, /// Index: Ringtoets/Common/src/Ringtoets.Common.Primitives/TailorMadeAssessmentResultType.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Primitives/TailorMadeAssessmentResultType.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Primitives/TailorMadeAssessmentResultType.cs (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -0,0 +1,69 @@ +// Copyright (C) Stichting Deltares 2017. 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 Core.Common.Util.Attributes; +using Ringtoets.Common.Primitives.Properties; + +namespace Ringtoets.Common.Primitives +{ + /// + /// This enum defines the possible result types for a tailor made assessment + /// on a failure mechanism section. + /// + public enum TailorMadeAssessmentResultType + { + /// + /// No option has been selected for this failure + /// mechanism section. + /// + [ResourcesDisplayName(typeof(Resources), nameof(Resources.AssessmentResultType_None))] + None = 1, + + /// + /// The calculated probability for this failure + /// mechanism section has to be entered. + /// + [ResourcesDisplayName(typeof(Resources), nameof(Resources.AssessmentResultType_Probability))] + Probability = 2, + + /// + /// The assessment for this failure mechanism + /// section was sufficient. + /// + [ResourcesDisplayName(typeof(Resources), nameof(Resources.TailorMadeAssessmentResultType_Sufficient))] + Sufficient = 3, + + /// + /// The assessment for this failure mechanism + /// section was insufficient. + /// + [ResourcesDisplayName(typeof(Resources), nameof(Resources.TailorMadeAssessmentResultType_Insufficient))] + Insufficient = 4, + + /// + /// No assessment has been performed for this failure + /// mechanism section. + /// + [ResourcesDisplayName(typeof(Resources), nameof(Resources.AssessmentResultType_NotAssessed))] + NotAssessed = 5 + + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Builders/FailureMechanismSectionResultColumnBuilderTest.cs =================================================================== diff -u -ra0cc5b43d22f89e997877215a505f6fab58aa70b -ree067be0b11728670314dd61f2dd885fd69f82ea --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Builders/FailureMechanismSectionResultColumnBuilderTest.cs (.../FailureMechanismSectionResultColumnBuilderTest.cs) (revision a0cc5b43d22f89e997877215a505f6fab58aa70b) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Builders/FailureMechanismSectionResultColumnBuilderTest.cs (.../FailureMechanismSectionResultColumnBuilderTest.cs) (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -20,22 +20,31 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using Core.Common.Controls.DataGrid; using Core.Common.Util; using NUnit.Extensions.Forms; using NUnit.Framework; -using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.Builders; -using Ringtoets.Common.Forms.Test.Views; using Ringtoets.Common.Primitives; namespace Ringtoets.Common.Forms.Test.Builders { [TestFixture] public class FailureMechanismSectionResultColumnBuilderTest { + private static IEnumerable> CreateExpectedEnumDisplayWrappers() + { + return Enum.GetValues(typeof(T)) + .OfType() + .Select(e => new EnumDisplayWrapper(e)) + .ToArray(); + } + + #region Simple Assessment + [Test] public void AddSimpleAssessmentResultColumn_DataGridViewControlNull_ThrowsArgumentNullException() { @@ -71,11 +80,6 @@ form.Show(); var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - control.SetDataSource(new[] - { - new TestFailureMechanismSectionResultRow(FailureMechanismSectionResultTestFactory.CreateFailureMechanismSectionResult()) - }); - // Precondition Assert.AreEqual(0, dataGridView.ColumnCount); @@ -86,27 +90,261 @@ Assert.AreEqual(1, dataGridView.ColumnCount); var columnData = (DataGridViewComboBoxColumn) dataGridView.Columns[0]; - Assert.AreEqual(dataPropertyName, columnData.DataPropertyName); Assert.AreEqual("Eenvoudige toets", columnData.HeaderText); Assert.AreEqual("Value", columnData.ValueMember); Assert.AreEqual("DisplayName", columnData.DisplayMember); - EnumDisplayWrapper[] expectedDataSource = Enum.GetValues(typeof(SimpleAssessmentResultType)) - .OfType() - .Select(sa => new EnumDisplayWrapper(sa)) - .ToArray(); + IEnumerable> expectedDataSource = CreateExpectedEnumDisplayWrappers(); var actualDataSource = (EnumDisplayWrapper[]) columnData.DataSource; - Assert.AreEqual(expectedDataSource.Length, actualDataSource.Length); + Assert.AreEqual(expectedDataSource.Count(), actualDataSource.Length); for (var i = 0; i < actualDataSource.Length; i++) { - EnumDisplayWrapper expectedWrapper = expectedDataSource[i]; + EnumDisplayWrapper expectedWrapper = expectedDataSource.ElementAt(i); EnumDisplayWrapper actualWrapper = actualDataSource[i]; Assert.AreEqual(expectedWrapper.Value, actualWrapper.Value); Assert.AreEqual(expectedWrapper.DisplayName, actualWrapper.DisplayName); } } } + + #endregion + + #region Detailed Assessment + + [Test] + public void AddDetailedAssessmentResultColumn_DataGridViewControlNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => FailureMechanismSectionResultColumnBuilder.AddDetailedAssessmentResultColumn(null, "property"); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("dataGridViewControl", exception.ParamName); + } + + [Test] + public void AddDetailedAssessmentResultColumn_DataPropertyNameNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => FailureMechanismSectionResultColumnBuilder.AddDetailedAssessmentResultColumn(new DataGridViewControl(), null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("dataPropertyName", exception.ParamName); + } + + [Test] + public void AddDetailedAssessmentResultColumn_WithParameters_AddsColumnToDataGridViewControl() + { + // Setup + const string dataPropertyName = "test property"; + + using (var form = new Form()) + using (var control = new DataGridViewControl()) + { + form.Controls.Add(control); + form.Show(); + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Precondition + Assert.AreEqual(0, dataGridView.ColumnCount); + + // Call + FailureMechanismSectionResultColumnBuilder.AddDetailedAssessmentResultColumn(control, dataPropertyName); + + // Assert + Assert.AreEqual(1, dataGridView.ColumnCount); + + var columnData = (DataGridViewComboBoxColumn) dataGridView.Columns[0]; + Assert.AreEqual(dataPropertyName, columnData.DataPropertyName); + Assert.AreEqual("Gedetailleerde toets per vak", columnData.HeaderText); + Assert.AreEqual("Value", columnData.ValueMember); + Assert.AreEqual("DisplayName", columnData.DisplayMember); + + IEnumerable> expectedDataSource = CreateExpectedEnumDisplayWrappers(); + var actualDataSource = (EnumDisplayWrapper[]) columnData.DataSource; + + Assert.AreEqual(expectedDataSource.Count(), actualDataSource.Length); + for (var i = 0; i < actualDataSource.Length; i++) + { + EnumDisplayWrapper expectedWrapper = expectedDataSource.ElementAt(i); + EnumDisplayWrapper actualWrapper = actualDataSource[i]; + Assert.AreEqual(expectedWrapper.Value, actualWrapper.Value); + Assert.AreEqual(expectedWrapper.DisplayName, actualWrapper.DisplayName); + } + } + } + + [Test] + public void AddDetailedAssessmentProbabilityColumn_DataGridViewControlNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => FailureMechanismSectionResultColumnBuilder.AddDetailedAssessmentProbabilityColumn(null, "property"); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("dataGridViewControl", exception.ParamName); + } + + [Test] + public void AddDetailedAssessmentProbabilityColumn_DataPropertyNameNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => FailureMechanismSectionResultColumnBuilder.AddDetailedAssessmentProbabilityColumn(new DataGridViewControl(), null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("dataPropertyName", exception.ParamName); + } + + [Test] + public void AddDetailedAssessmentProbabilityColumn_WithParameters_AddsColumnToDataGridViewControl() + { + // Setup + const string dataPropertyName = "test property"; + + using (var form = new Form()) + using (var control = new DataGridViewControl()) + { + form.Controls.Add(control); + form.Show(); + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Precondition + Assert.AreEqual(0, dataGridView.ColumnCount); + + // Call + FailureMechanismSectionResultColumnBuilder.AddDetailedAssessmentProbabilityColumn(control, dataPropertyName); + + // Assert + Assert.AreEqual(1, dataGridView.ColumnCount); + + var columnData = (DataGridViewTextBoxColumn) dataGridView.Columns[0]; + Assert.AreEqual(dataPropertyName, columnData.DataPropertyName); + Assert.AreEqual("Gedetailleerde toets per vak\r\nFaalkans", columnData.HeaderText); + } + } + + #endregion + + #region Tailor Made Assessment + + [Test] + public void AddTailorMadeAssessmentResultColumn_DataGridViewControlNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => FailureMechanismSectionResultColumnBuilder.AddTailorMadeAssessmentResultColumn(null, "property"); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("dataGridViewControl", exception.ParamName); + } + + [Test] + public void AddTailorMadeAssessmentResultColumn_DataPropertyNameNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => FailureMechanismSectionResultColumnBuilder.AddTailorMadeAssessmentResultColumn(new DataGridViewControl(), null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("dataPropertyName", exception.ParamName); + } + + [Test] + public void AddTailorMadeAssessmentResultColumn_WithParameters_AddsColumnToDataGridViewControl() + { + // Setup + const string dataPropertyName = "test property"; + + using (var form = new Form()) + using (var control = new DataGridViewControl()) + { + form.Controls.Add(control); + form.Show(); + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Precondition + Assert.AreEqual(0, dataGridView.ColumnCount); + + // Call + FailureMechanismSectionResultColumnBuilder.AddTailorMadeAssessmentResultColumn(control, dataPropertyName); + + // Assert + Assert.AreEqual(1, dataGridView.ColumnCount); + + var columnData = (DataGridViewComboBoxColumn) dataGridView.Columns[0]; + Assert.AreEqual(dataPropertyName, columnData.DataPropertyName); + Assert.AreEqual("Toets op maat", columnData.HeaderText); + Assert.AreEqual("Value", columnData.ValueMember); + Assert.AreEqual("DisplayName", columnData.DisplayMember); + + IEnumerable> expectedDataSource = CreateExpectedEnumDisplayWrappers(); + var actualDataSource = (EnumDisplayWrapper[]) columnData.DataSource; + + Assert.AreEqual(expectedDataSource.Count(), actualDataSource.Length); + for (var i = 0; i < actualDataSource.Length; i++) + { + EnumDisplayWrapper expectedWrapper = expectedDataSource.ElementAt(i); + EnumDisplayWrapper actualWrapper = actualDataSource[i]; + Assert.AreEqual(expectedWrapper.Value, actualWrapper.Value); + Assert.AreEqual(expectedWrapper.DisplayName, actualWrapper.DisplayName); + } + } + } + + [Test] + public void AddTailorMadeAssessmentProbabilityColumn_DataGridViewControlNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => FailureMechanismSectionResultColumnBuilder.AddTailorMadeAssessmentProbabilityColumn(null, "property"); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("dataGridViewControl", exception.ParamName); + } + + [Test] + public void AddTailorMadeAssessmentProbabilityColumn_DataPropertyNameNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => FailureMechanismSectionResultColumnBuilder.AddTailorMadeAssessmentProbabilityColumn(new DataGridViewControl(), null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("dataPropertyName", exception.ParamName); + } + + [Test] + public void AddTailorMadeAssessmentProbabilityColumn_WithParameters_AddsColumnToDataGridViewControl() + { + // Setup + const string dataPropertyName = "test property"; + + using (var form = new Form()) + using (var control = new DataGridViewControl()) + { + form.Controls.Add(control); + form.Show(); + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Precondition + Assert.AreEqual(0, dataGridView.ColumnCount); + + // Call + FailureMechanismSectionResultColumnBuilder.AddTailorMadeAssessmentProbabilityColumn(control, dataPropertyName); + + // Assert + Assert.AreEqual(1, dataGridView.ColumnCount); + + var columnData = (DataGridViewTextBoxColumn) dataGridView.Columns[0]; + Assert.AreEqual(dataPropertyName, columnData.DataPropertyName); + Assert.AreEqual("Toets op maat\r\nFaalkans", columnData.HeaderText); + } + } + + #endregion } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Primitives.Test/DetailedAssessmentResultTypeTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Primitives.Test/DetailedAssessmentResultTypeTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Primitives.Test/DetailedAssessmentResultTypeTest.cs (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -0,0 +1,63 @@ +// Copyright (C) Stichting Deltares 2017. 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 Core.Common.TestUtil; +using NUnit.Framework; + +namespace Ringtoets.Common.Primitives.Test +{ + [TestFixture] + public class DetailedAssessmentResultTypeTest : EnumWithDisplayNameTestFixture + { + protected override IDictionary ExpectedValueForEnumValues + { + get + { + return new Dictionary + { + { + DetailedAssessmentResultType.Probability, 1 + }, + { + DetailedAssessmentResultType.NotAssessed, 2 + } + }; + } + } + + protected override IDictionary ExpectedDisplayNameForEnumValues + { + get + { + return new Dictionary + { + { + DetailedAssessmentResultType.Probability, "Faalkans" + }, + { + DetailedAssessmentResultType.NotAssessed, "NGO" + } + }; + } + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Primitives.Test/Ringtoets.Common.Primitives.Test.csproj =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -ree067be0b11728670314dd61f2dd885fd69f82ea --- Ringtoets/Common/test/Ringtoets.Common.Primitives.Test/Ringtoets.Common.Primitives.Test.csproj (.../Ringtoets.Common.Primitives.Test.csproj) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/Common/test/Ringtoets.Common.Primitives.Test/Ringtoets.Common.Primitives.Test.csproj (.../Ringtoets.Common.Primitives.Test.csproj) (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -14,7 +14,9 @@ + + Index: Ringtoets/Common/test/Ringtoets.Common.Primitives.Test/TailorMadeAssessmentResultTypeTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Primitives.Test/TailorMadeAssessmentResultTypeTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Primitives.Test/TailorMadeAssessmentResultTypeTest.cs (revision ee067be0b11728670314dd61f2dd885fd69f82ea) @@ -0,0 +1,81 @@ +// Copyright (C) Stichting Deltares 2017. 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 Core.Common.TestUtil; +using NUnit.Framework; + +namespace Ringtoets.Common.Primitives.Test +{ + [TestFixture] + public class TailorMadeAssessmentResultTypeTest : EnumWithDisplayNameTestFixture + { + protected override IDictionary ExpectedValueForEnumValues + { + get + { + return new Dictionary + { + { + TailorMadeAssessmentResultType.None, 1 + }, + { + TailorMadeAssessmentResultType.Probability, 2 + }, + { + TailorMadeAssessmentResultType.Sufficient, 3 + }, + { + TailorMadeAssessmentResultType.Insufficient, 4 + }, + { + TailorMadeAssessmentResultType.NotAssessed, 5 + } + }; + } + } + + protected override IDictionary ExpectedDisplayNameForEnumValues + { + get + { + return new Dictionary + { + { + TailorMadeAssessmentResultType.None, "" + }, + { + TailorMadeAssessmentResultType.Probability, "Faalkans" + }, + { + TailorMadeAssessmentResultType.Sufficient, "V" + }, + { + TailorMadeAssessmentResultType.Insufficient, "VN" + }, + { + TailorMadeAssessmentResultType.NotAssessed, "NGO" + } + }; + } + } + } +} \ No newline at end of file