Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyCategoryGroupControlTest.cs =================================================================== diff -u -r84223425c4ab8eec2440f512b5b06bea8937f8f9 -r5f24b9f44bf75f735f6b9171ec6ce482fa0dcc7f --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyCategoryGroupControlTest.cs (.../FailureMechanismAssemblyCategoryGroupControlTest.cs) (revision 84223425c4ab8eec2440f512b5b06bea8937f8f9) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyCategoryGroupControlTest.cs (.../FailureMechanismAssemblyCategoryGroupControlTest.cs) (revision 5f24b9f44bf75f735f6b9171ec6ce482fa0dcc7f) @@ -52,17 +52,17 @@ { // Setup var random = new Random(39); - var assembly = random.NextEnumValue(); + var result = random.NextEnumValue(); using (var resultControl = new FailureMechanismAssemblyCategoryGroupControl()) { // Call - resultControl.SetAssemblyResult(assembly); + resultControl.SetAssemblyResult(result); // Assert BorderedLabel groupLabel = GetGroupLabel(resultControl); - Assert.AreEqual(new EnumDisplayWrapper(assembly).DisplayName, + Assert.AreEqual(new EnumDisplayWrapper(result).DisplayName, groupLabel.Text); - Assert.AreEqual(AssemblyCategoryGroupColorHelper.GetFailureMechanismAssemblyCategoryGroupColor(assembly), + Assert.AreEqual(AssemblyCategoryGroupColorHelper.GetFailureMechanismAssemblyCategoryGroupColor(result), groupLabel.BackColor); } } @@ -83,7 +83,7 @@ } } - private static BorderedLabel GetGroupLabel(AssemblyResultControl resultControl) + private static BorderedLabel GetGroupLabel(FailureMechanismAssemblyCategoryGroupControl resultControl) { return (BorderedLabel) ((TableLayoutPanel) resultControl.Controls["GroupPanel"]).GetControlFromPosition(0, 0); } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyControlTest.cs =================================================================== diff -u -r84223425c4ab8eec2440f512b5b06bea8937f8f9 -r5f24b9f44bf75f735f6b9171ec6ce482fa0dcc7f --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyControlTest.cs (.../FailureMechanismAssemblyControlTest.cs) (revision 84223425c4ab8eec2440f512b5b06bea8937f8f9) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyControlTest.cs (.../FailureMechanismAssemblyControlTest.cs) (revision 5f24b9f44bf75f735f6b9171ec6ce482fa0dcc7f) @@ -68,23 +68,23 @@ { // Setup var random = new Random(39); - var assembly = new FailureMechanismAssembly(random.NextDouble(), - random.NextEnumValue()); + var result = new FailureMechanismAssembly(random.NextDouble(), + random.NextEnumValue()); using (var resultControl = new FailureMechanismAssemblyControl()) { // Call - resultControl.SetAssemblyResult(assembly); + resultControl.SetAssemblyResult(result); // Assert Control groupLabel = GetGroupLabel(resultControl); Control probabilityLabel = GetProbabilityLabel(resultControl); - Assert.AreEqual(new EnumDisplayWrapper(assembly.Group).DisplayName, + Assert.AreEqual(new EnumDisplayWrapper(result.Group).DisplayName, groupLabel.Text); - Assert.AreEqual(AssemblyCategoryGroupColorHelper.GetFailureMechanismAssemblyCategoryGroupColor(assembly.Group), + Assert.AreEqual(AssemblyCategoryGroupColorHelper.GetFailureMechanismAssemblyCategoryGroupColor(result.Group), groupLabel.BackColor); - Assert.AreEqual(new NoProbabilityValueDoubleConverter().ConvertToString(assembly.Probability), + Assert.AreEqual(new NoProbabilityValueDoubleConverter().ConvertToString(result.Probability), probabilityLabel.Text); } } @@ -107,12 +107,12 @@ } } - private static BorderedLabel GetGroupLabel(AssemblyResultControl resultControl) + private static BorderedLabel GetGroupLabel(FailureMechanismAssemblyControl resultControl) { return (BorderedLabel) ((TableLayoutPanel) resultControl.Controls["GroupPanel"]).GetControlFromPosition(0, 0); } - private static BorderedLabel GetProbabilityLabel(AssemblyResultControl resultControl) + private static BorderedLabel GetProbabilityLabel(FailureMechanismAssemblyControl resultControl) { return (BorderedLabel) ((TableLayoutPanel) resultControl.Controls["probabilityPanel"]).GetControlFromPosition(0, 0); } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Controls/AssessmentSectionAssemblyCategoryGroupControl.cs =================================================================== diff -u -r44dbc30e3704795e6c88dd02296dc814eb4536bc -r5f24b9f44bf75f735f6b9171ec6ce482fa0dcc7f --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Controls/AssessmentSectionAssemblyCategoryGroupControl.cs (.../AssessmentSectionAssemblyCategoryGroupControl.cs) (revision 44dbc30e3704795e6c88dd02296dc814eb4536bc) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Controls/AssessmentSectionAssemblyCategoryGroupControl.cs (.../AssessmentSectionAssemblyCategoryGroupControl.cs) (revision 5f24b9f44bf75f735f6b9171ec6ce482fa0dcc7f) @@ -26,12 +26,19 @@ namespace Ringtoets.Integration.Forms.Controls { + /// + /// Custom control to display a . + /// public class AssessmentSectionAssemblyCategoryGroupControl : AssemblyResultControl { - public void SetData(AssessmentSectionAssemblyCategoryGroup category) + /// + /// Set the value of on the control. + /// + /// The to set on the control. + public void SetAssemblyResult(AssessmentSectionAssemblyCategoryGroup result) { - GroupLabel.Text = new EnumDisplayWrapper(category).DisplayName; - GroupLabel.BackColor = AssemblyCategoryGroupColorHelper.GetAssessmentSectionAssemblyCategoryGroupColor(category); + GroupLabel.Text = new EnumDisplayWrapper(result).DisplayName; + GroupLabel.BackColor = AssemblyCategoryGroupColorHelper.GetAssessmentSectionAssemblyCategoryGroupColor(result); } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Controls/AssessmentSectionAssemblyControl.cs =================================================================== diff -u -r44dbc30e3704795e6c88dd02296dc814eb4536bc -r5f24b9f44bf75f735f6b9171ec6ce482fa0dcc7f --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Controls/AssessmentSectionAssemblyControl.cs (.../AssessmentSectionAssemblyControl.cs) (revision 44dbc30e3704795e6c88dd02296dc814eb4536bc) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Controls/AssessmentSectionAssemblyControl.cs (.../AssessmentSectionAssemblyControl.cs) (revision 5f24b9f44bf75f735f6b9171ec6ce482fa0dcc7f) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Core.Common.Util; using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Forms.Controls; @@ -27,14 +28,27 @@ namespace Ringtoets.Integration.Forms.Controls { + /// + /// Custom control to display a . + /// public class AssessmentSectionAssemblyControl : AssemblyResultWithProbabilityControl { - public void SetData(AssessmentSectionAssembly assembly) + /// + /// Set the values of on the control. + /// + /// The to set on the control. + /// Thrown when is null. + public void SetAssemblyResult(AssessmentSectionAssembly result) { - GroupLabel.Text = new EnumDisplayWrapper(assembly.Group).DisplayName; - GroupLabel.BackColor = AssemblyCategoryGroupColorHelper.GetAssessmentSectionAssemblyCategoryGroupColor(assembly.Group); + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } - ProbabilityLabel.Text = new NoProbabilityValueDoubleConverter().ConvertToString(assembly.Probability); + GroupLabel.Text = new EnumDisplayWrapper(result.Group).DisplayName; + GroupLabel.BackColor = AssemblyCategoryGroupColorHelper.GetAssessmentSectionAssemblyCategoryGroupColor(result.Group); + + ProbabilityLabel.Text = new NoProbabilityValueDoubleConverter().ConvertToString(result.Probability); } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Controls/AssessmentSectionAssemblyCategoryGroupControlTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Controls/AssessmentSectionAssemblyCategoryGroupControlTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Controls/AssessmentSectionAssemblyCategoryGroupControlTest.cs (revision 5f24b9f44bf75f735f6b9171ec6ce482fa0dcc7f) @@ -0,0 +1,91 @@ +// 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; +using System.Drawing; +using System.Windows.Forms; +using Core.Common.Controls; +using Core.Common.TestUtil; +using Core.Common.Util; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.Common.Forms.Controls; +using Ringtoets.Common.Forms.Helpers; +using Ringtoets.Integration.Forms.Controls; + +namespace Ringtoets.Integration.Forms.Test.Controls +{ + public class AssessmentSectionAssemblyCategoryGroupControlTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + using (var resultControl = new AssessmentSectionAssemblyCategoryGroupControl()) + { + // Assert + Assert.AreEqual(1, resultControl.Controls.Count); + Assert.IsInstanceOf(resultControl); + } + } + + [Test] + public void SetAssemblyResult_WithResult_SetsValues() + { + // Setup + var random = new Random(39); + var result = random.NextEnumValue(); + using (var resultControl = new AssessmentSectionAssemblyCategoryGroupControl()) + { + // Call + resultControl.SetAssemblyResult(result); + + // Assert + BorderedLabel groupLabel = GetGroupLabel(resultControl); + Assert.AreEqual(new EnumDisplayWrapper(result).DisplayName, + groupLabel.Text); + Assert.AreEqual(AssemblyCategoryGroupColorHelper.GetAssessmentSectionAssemblyCategoryGroupColor(result), + groupLabel.BackColor); + } + } + + [Test] + public void ClearData_Always_ClearsDataOnControl() + { + // Setup + using (var resultControl = new AssessmentSectionAssemblyCategoryGroupControl()) + { + // Call + resultControl.ClearData(); + + // Assert + BorderedLabel groupLabel = GetGroupLabel(resultControl); + Assert.IsEmpty(groupLabel.Text); + Assert.AreEqual(Color.White, groupLabel.BackColor); + } + } + + private static BorderedLabel GetGroupLabel(AssessmentSectionAssemblyCategoryGroupControl resultControl) + { + return (BorderedLabel) ((TableLayoutPanel) resultControl.Controls["GroupPanel"]).GetControlFromPosition(0, 0); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Controls/AssessmentSectionAssemblyControlTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Controls/AssessmentSectionAssemblyControlTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Controls/AssessmentSectionAssemblyControlTest.cs (revision 5f24b9f44bf75f735f6b9171ec6ce482fa0dcc7f) @@ -0,0 +1,120 @@ +// 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; +using System.Drawing; +using System.Windows.Forms; +using Core.Common.Controls; +using Core.Common.TestUtil; +using Core.Common.Util; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.Common.Forms.Controls; +using Ringtoets.Common.Forms.Helpers; +using Ringtoets.Common.Forms.TypeConverters; +using Ringtoets.Integration.Forms.Controls; + +namespace Ringtoets.Integration.Forms.Test.Controls +{ + public class AssessmentSectionAssemblyControlTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + using (var resultControl = new AssessmentSectionAssemblyControl()) + { + // Assert + Assert.AreEqual(2, resultControl.Controls.Count); + Assert.IsInstanceOf(resultControl); + } + } + + [Test] + public void SetAssemblyResult_ResultNull_ThrowsArgumentNullException() + { + // Setup + using (var resultControl = new AssessmentSectionAssemblyControl()) + { + // Call + TestDelegate test = () => resultControl.SetAssemblyResult(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("result", exception.ParamName); + } + } + + [Test] + public void SetAssemblyResult_WithResult_SetsValuesOnControl() + { + // Setup + var random = new Random(39); + var result = new AssessmentSectionAssembly(random.NextDouble(), + random.NextEnumValue()); + using (var resultControl = new AssessmentSectionAssemblyControl()) + { + // Call + resultControl.SetAssemblyResult(result); + + // Assert + Control groupLabel = GetGroupLabel(resultControl); + Control probabilityLabel = GetProbabilityLabel(resultControl); + + Assert.AreEqual(new EnumDisplayWrapper(result.Group).DisplayName, + groupLabel.Text); + Assert.AreEqual(AssemblyCategoryGroupColorHelper.GetAssessmentSectionAssemblyCategoryGroupColor(result.Group), + groupLabel.BackColor); + + Assert.AreEqual(new NoProbabilityValueDoubleConverter().ConvertToString(result.Probability), + probabilityLabel.Text); + } + } + + [Test] + public void ClearData_Always_ClearsDataOnControl() + { + // Setup + using (var resultControl = new AssessmentSectionAssemblyControl()) + { + // Call + resultControl.ClearData(); + + // Assert + BorderedLabel groupLabel = GetGroupLabel(resultControl); + BorderedLabel probabilityLabel = GetProbabilityLabel(resultControl); + Assert.IsEmpty(groupLabel.Text); + Assert.AreEqual(Color.White, groupLabel.BackColor); + Assert.AreEqual("-", probabilityLabel.Text); + } + } + + private static BorderedLabel GetGroupLabel(AssessmentSectionAssemblyControl resultControl) + { + return (BorderedLabel) ((TableLayoutPanel) resultControl.Controls["GroupPanel"]).GetControlFromPosition(0, 0); + } + + private static BorderedLabel GetProbabilityLabel(AssessmentSectionAssemblyControl resultControl) + { + return (BorderedLabel) ((TableLayoutPanel) resultControl.Controls["probabilityPanel"]).GetControlFromPosition(0, 0); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -rd61d7132f071bfb24f72fba861f85b7a35814b5d -r5f24b9f44bf75f735f6b9171ec6ce482fa0dcc7f --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision d61d7132f071bfb24f72fba861f85b7a35814b5d) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 5f24b9f44bf75f735f6b9171ec6ce482fa0dcc7f) @@ -36,6 +36,8 @@ + +