Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyResultControlTest.cs =================================================================== diff -u -re066f6fce8df4604082ede0fcd13921a8d66c560 -r718d74086633d91a350d60a463715d3bd360468b --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyResultControlTest.cs (.../FailureMechanismAssemblyResultControlTest.cs) (revision e066f6fce8df4604082ede0fcd13921a8d66c560) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyResultControlTest.cs (.../FailureMechanismAssemblyResultControlTest.cs) (revision 718d74086633d91a350d60a463715d3bd360468b) @@ -23,9 +23,12 @@ using System.Drawing; using System.Windows.Forms; using Core.Common.TestUtil; +using Core.Common.Util; using Core.Common.Util.Reflection; using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Forms.Controls; +using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.Properties; namespace Ringtoets.Common.Forms.Test.Controls @@ -44,7 +47,7 @@ Assert.IsInstanceOf(resultControl); Assert.IsTrue(resultControl.AutoSize); - var groupPanel = TypeUtils.GetField(resultControl, "GroupPanel"); + TableLayoutPanel groupPanel = GetGroupPanel(resultControl); Assert.AreEqual(2, groupPanel.ColumnCount); Assert.AreEqual(1, groupPanel.RowCount); @@ -64,6 +67,41 @@ } [Test] + public void SetAssemblyResult_AssemblyNull_ThrowsArgumentNullException() + { + // Setup + var resultControl = new FailureMechanismAssemblyResultWithProbabilityControl(); + + // Call + TestDelegate test = () => resultControl.SetAssemblyResult(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("assembly", exception.ParamName); + } + + [Test] + public void SetAssemblyResult_WithAssembly_SetsValuesOnControl() + { + // Setup + var random = new Random(39); + var assembly = new FailureMechanismAssembly(random.NextDouble(), + random.NextEnumValue()); + var resultControl = new FailureMechanismAssemblyResultControl(); + + // Call + resultControl.SetAssemblyResult(assembly); + + // Assert + Control groupLabel = GetGroupPanel(resultControl).GetControlFromPosition(1, 0); + + Assert.AreEqual(new EnumDisplayWrapper(assembly.Group).DisplayName, + groupLabel.Text); + Assert.AreEqual(AssemblyCategoryGroupColorHelper.GetFailureMechanismAssemblyCategoryGroupColor(assembly.Group), + groupLabel.BackColor); + } + + [Test] public void SetError_ErrorNull_ThrowsArgumentNullException() { // Setup @@ -110,5 +148,10 @@ { return TypeUtils.GetField(resultControl, "ErrorProvider"); } + + private static TableLayoutPanel GetGroupPanel(FailureMechanismAssemblyResultControl resultControl) + { + return TypeUtils.GetField(resultControl, "GroupPanel"); + } } } \ No newline at end of file