Index: Core/Common/src/Core.Common.Controls.Swf/TreeViewControls/ITreeView.cs =================================================================== diff -u -rd37e350b3c62d61768313c57c2d8d8d05d22458a -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Core/Common/src/Core.Common.Controls.Swf/TreeViewControls/ITreeView.cs (.../ITreeView.cs) (revision d37e350b3c62d61768313c57c2d8d8d05d22458a) +++ Core/Common/src/Core.Common.Controls.Swf/TreeViewControls/ITreeView.cs (.../ITreeView.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -10,12 +10,12 @@ public interface ITreeView : IView { /// - /// Event to notify observers of changes in the selection + /// Event to notify observers of changes in the selection. /// event EventHandler SelectedNodeChanged; /// - /// Event to notify observers of changes in the tree structure + /// Event to notify observers of changes in the tree structure. /// event EventHandler OnUpdate; Index: Core/Common/src/Core.Common.Controls.Swf/TreeViewControls/TreeView.cs =================================================================== diff -u -r752bf12bb8b00ba1d544d0b7f2f8ce8ce4b1b75a -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Core/Common/src/Core.Common.Controls.Swf/TreeViewControls/TreeView.cs (.../TreeView.cs) (revision 752bf12bb8b00ba1d544d0b7f2f8ce8ce4b1b75a) +++ Core/Common/src/Core.Common.Controls.Swf/TreeViewControls/TreeView.cs (.../TreeView.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -292,7 +292,7 @@ } /// - /// Fires the OnUpdate event with the given . + /// Fires the event with the given . /// /// The to fire an update event for. private void FireOnUpdateEvent(ITreeNode treeNode) Index: Core/Common/src/Core.Common.Gui/Forms/ViewManager/ViewResolver.cs =================================================================== diff -u -ra600b08ffb5dac8164691824fe6dc7f4e96814d0 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Core/Common/src/Core.Common.Gui/Forms/ViewManager/ViewResolver.cs (.../ViewResolver.cs) (revision a600b08ffb5dac8164691824fe6dc7f4e96814d0) +++ Core/Common/src/Core.Common.Gui/Forms/ViewManager/ViewResolver.cs (.../ViewResolver.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -180,7 +180,7 @@ var viewsToCheck = views.ToList(); foreach (var view in viewsToCheck) { - if (IsViewData(view, data) || extraCheck == null || extraCheck(view, data)) + if (IsViewData(view, data) || (extraCheck != null && extraCheck(view, data))) { viewAction(view); } Index: Core/Common/src/Core.Common.Gui/IGui.cs =================================================================== diff -u -rd37e350b3c62d61768313c57c2d8d8d05d22458a -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Core/Common/src/Core.Common.Gui/IGui.cs (.../IGui.cs) (revision d37e350b3c62d61768313c57c2d8d8d05d22458a) +++ Core/Common/src/Core.Common.Gui/IGui.cs (.../IGui.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -153,7 +153,6 @@ /// Update the tool tip for every view currently open. Reasons for doing so /// include the modification of the tree structure which is reflected in a tool tip. /// - /// void UpdateToolTips(); #endregion Index: Core/Common/test/Core.Common.TestUtil/TestHelper.cs =================================================================== diff -u -rf42e31958888a2a09de2686d2805cb48595ba6e0 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Core/Common/test/Core.Common.TestUtil/TestHelper.cs (.../TestHelper.cs) (revision f42e31958888a2a09de2686d2805cb48595ba6e0) +++ Core/Common/test/Core.Common.TestUtil/TestHelper.cs (.../TestHelper.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -350,6 +350,25 @@ } } + /// + /// Asserts that the exception is of type and that the custom part of + /// is equal to . + /// + /// The type of the expected exception. + /// The test to execute and should throw exception of type . + /// The expected custom part of the exception message. + /// Can only be used when does not contain . + /// + public static void AssertExceptionCustomMessage(TestDelegate test, string expectedCustomMessage) where T : Exception + { + var message = Assert.Throws(test).Message; + var customMessage = message.Split(new[] + { + Environment.NewLine + }, StringSplitOptions.None)[0]; + Assert.AreEqual(expectedCustomMessage, customMessage); + } + private static string GetCurrentTestClassMethodName() { var stackTrace = new StackTrace(false); @@ -644,7 +663,7 @@ expectedImage.Save(stream, expectedImage.RawFormat); var length = stream.Length; var imageBytes = new byte[length]; - stream.Read(imageBytes, 0, (int)length); + stream.Read(imageBytes, 0, (int) length); return imageBytes; } } Index: Core/Common/test/Core.Common.Utils.Test/TestHelperTests.cs =================================================================== diff -u -rf42e31958888a2a09de2686d2805cb48595ba6e0 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Core/Common/test/Core.Common.Utils.Test/TestHelperTests.cs (.../TestHelperTests.cs) (revision f42e31958888a2a09de2686d2805cb48595ba6e0) +++ Core/Common/test/Core.Common.Utils.Test/TestHelperTests.cs (.../TestHelperTests.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -1,4 +1,5 @@ -using System.Drawing; +using System; +using System.Drawing; using System.Globalization; using System.IO; using System.Linq; @@ -270,7 +271,7 @@ [Test] [TestCase(true)] [TestCase(false)] - public void AssertContextMenuStripContainsItem_MenuItemWithDifferentEnabeldState_NoExceptions(bool enabled) + public void AssertContextMenuStripContainsItem_MenuItemWithDifferentEnabeldState_ThrowsAssertionException(bool enabled) { // Setup var contextMenuStrip = new ContextMenuStrip(); @@ -300,6 +301,51 @@ TestHelper.AssertContextMenuStripContainsItem(contextMenuStrip, 0, testItem.Text, testItem.ToolTipText, testItem.Image); } + [Test] + public void AssertExceptionCustomMessage_NoException_ThrowsAssertionException() + { + // Setup + TestDelegate t = () => { }; + + // Call + TestDelegate call = () => + { + TestHelper.AssertExceptionCustomMessage(t, String.Empty); + }; + + // Assert + Assert.Throws(call); + } + + [Test] + public void AssertExceptionCustomMessage_ExceptionIncorrectMessage_ThrowsAssertionException() + { + // Setup + var someMessage = "Exception"; + var differentMessage = "Different"; + TestDelegate t = () => { throw new Exception(someMessage); }; + + // Call + TestDelegate call = () => + { + TestHelper.AssertExceptionCustomMessage(t, differentMessage); + }; + + // Assert + Assert.Throws(call); + } + + [Test] + public void AssertExceptionCustomMessage_ExceptionEqualMessage_NoExceptions() + { + // Setup + var someMessage = "Exception"; + TestDelegate t = () => { throw new Exception(someMessage); }; + + // Call & Assert + TestHelper.AssertExceptionCustomMessage(t, someMessage); + } + private static ToolStripMenuItem CreateContextMenuItem() { return new ToolStripMenuItem Index: Ringtoets/Common/src/Ringtoets.Common.Data/BaseFailureMechanism.cs =================================================================== diff -u -r40b8a20775439cde6edfcb177005e43c947886d2 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Common/src/Ringtoets.Common.Data/BaseFailureMechanism.cs (.../BaseFailureMechanism.cs) (revision 40b8a20775439cde6edfcb177005e43c947886d2) +++ Ringtoets/Common/src/Ringtoets.Common.Data/BaseFailureMechanism.cs (.../BaseFailureMechanism.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -20,7 +20,7 @@ } set { - if (value < 0 || value > 100) + if (value <= 0 || value > 100) { throw new ArgumentException(Resources.FailureMechanism_Contribution_Value_should_be_in_interval_0_100, "value"); } Index: Ringtoets/Common/src/Ringtoets.Common.Data/IFailureMechanism.cs =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Common/src/Ringtoets.Common.Data/IFailureMechanism.cs (.../IFailureMechanism.cs) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Common/src/Ringtoets.Common.Data/IFailureMechanism.cs (.../IFailureMechanism.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -11,7 +11,7 @@ /// Gets the amount of contribution as a percentage (0-100) for the /// as part of the overall verdict. /// - /// Thrown when the is not in interval [0-100]. + /// Thrown when the is not in interval (0-100]. double Contribution { get; set; } /// Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -79,7 +79,7 @@ } /// - /// Looks up a localized string similar to De waarde voor de toegestane bijdrage aan faalkans moet in interval [0-100] liggen.. + /// Looks up a localized string similar to De waarde voor de toegestane bijdrage aan faalkans moet in interval (0,100] liggen.. /// public static string FailureMechanism_Contribution_Value_should_be_in_interval_0_100 { get { Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -124,7 +124,7 @@ Randvoorwaarden - De waarde voor de toegestane bijdrage aan faalkans moet in interval [0-100] liggen. + De waarde voor de toegestane bijdrage aan faalkans moet in interval (0,100] liggen. Locaties Index: Ringtoets/Common/src/Ringtoets.Common.Placeholder/PlaceholderWithReadonlyName.cs =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Common/src/Ringtoets.Common.Placeholder/PlaceholderWithReadonlyName.cs (.../PlaceholderWithReadonlyName.cs) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Common/src/Ringtoets.Common.Placeholder/PlaceholderWithReadonlyName.cs (.../PlaceholderWithReadonlyName.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -1,11 +1,9 @@ -using Ringtoets.Common.Data; - -namespace Ringtoets.Common.Placeholder +namespace Ringtoets.Common.Placeholder { /// /// Simple placeholder object with only a name that cannot be changed. /// - public class PlaceholderWithReadonlyName : BaseFailureMechanism + public class PlaceholderWithReadonlyName { /// /// Initializes a new instance of the class. @@ -15,5 +13,10 @@ { Name = name; } + + /// + /// Gets the name of the placeholder. + /// + public string Name { get; private set; } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/BaseFailureMechanismTest.cs =================================================================== diff -u -r40b8a20775439cde6edfcb177005e43c947886d2 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/BaseFailureMechanismTest.cs (.../BaseFailureMechanismTest.cs) (revision 40b8a20775439cde6edfcb177005e43c947886d2) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/BaseFailureMechanismTest.cs (.../BaseFailureMechanismTest.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -17,8 +17,9 @@ [Test] [TestCase(101)] - [TestCase(-1)] + [TestCase(0)] [TestCase(-1e-6)] + [TestCase(-1)] [TestCase(100+1e-6)] public void Contribution_ValueOutsideValidRegion_ThrowsArgumentException(double value) { @@ -34,5 +35,24 @@ Assert.Throws(test); mockRepository.VerifyAll(); } + + [Test] + [TestCase(100)] + [TestCase(50)] + [TestCase(1e-9)] + public void Contribution_ValueIntsideValidRegion_DoesNotThrow(double value) + { + // Setup + var failureMechanism = mockRepository.StrictMock(); + + mockRepository.ReplayAll(); + + // Call + TestDelegate test = () => failureMechanism.Contribution = value; + + // Assert + Assert.DoesNotThrow(test); + mockRepository.VerifyAll(); + } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Contribution/FailureMechanismContribution.cs =================================================================== diff -u -r10b304d4b5cb2283801cdb16204baf2a42ab5967 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Contribution/FailureMechanismContribution.cs (.../FailureMechanismContribution.cs) (revision 10b304d4b5cb2283801cdb16204baf2a42ab5967) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Contribution/FailureMechanismContribution.cs (.../FailureMechanismContribution.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -8,7 +8,7 @@ namespace Ringtoets.Integration.Data.Contribution { /// - /// This class represents the distribution of contribution for all failure mechanism. + /// This class represents the distribution of all failure mechanism contributions. /// public class FailureMechanismContribution : Observable { @@ -37,7 +37,7 @@ { throw new ArgumentNullException("failureMechanisms", Resources.FailureMechanismContribution_FailureMechanismContribution_Can_not_create_FailureMechanismContribution_without_FailureMechanism_collection); } - this.norm = norm; + Norm = norm; failureMechanisms.ForEachElementDo(AddContributionItem); AddOtherContributionItem(otherContribution); } @@ -53,6 +53,10 @@ } set { + if (value <= 0) + { + throw new ArgumentException(Resources.FailureMechanismContributionItem_Norm_must_be_larger_than_zero); + } norm = value; distribution.ForEachElementDo(d => d.Norm = norm); } Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Contribution/FailureMechanismContributionItem.cs =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Contribution/FailureMechanismContributionItem.cs (.../FailureMechanismContributionItem.cs) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Contribution/FailureMechanismContributionItem.cs (.../FailureMechanismContributionItem.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -2,6 +2,8 @@ using Ringtoets.Common.Data; using Ringtoets.Integration.Data.Properties; +using CommonResources = Ringtoets.Common.Data.Properties.Resources; + namespace Ringtoets.Integration.Data.Contribution { /// @@ -39,6 +41,11 @@ public double Contribution { get; private set; } /// + /// Gets or sets the norm of the complete dike section. + /// + public double Norm { get; internal set; } + + /// /// Gets the probability space per year for the . /// public double ProbabilitySpace @@ -48,10 +55,5 @@ return (Norm / Contribution) * 100; } } - - /// - /// Gets or sets the norm of the complete dike section. - /// - internal double Norm { private get; set; } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Contribution/OtherFailureMechanism.cs =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Contribution/OtherFailureMechanism.cs (.../OtherFailureMechanism.cs) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Contribution/OtherFailureMechanism.cs (.../OtherFailureMechanism.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -1,6 +1,5 @@ -using System; -using Ringtoets.Common.Data; -using Ringtoets.Integration.Data.Properties; +using Ringtoets.Common.Data; +using RingtoetsIntegrationResources = Ringtoets.Integration.Data.Properties.Resources; namespace Ringtoets.Integration.Data.Contribution { @@ -15,7 +14,7 @@ /// public OtherFailureMechanism() { - Name = Resources.OtherFailureMechanism_DisplayName; + Name = RingtoetsIntegrationResources.OtherFailureMechanism_DisplayName; } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Placeholders/FailureMechanismPlaceholder.cs =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Placeholders/FailureMechanismPlaceholder.cs (.../FailureMechanismPlaceholder.cs) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Placeholders/FailureMechanismPlaceholder.cs (.../FailureMechanismPlaceholder.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -7,18 +7,19 @@ /// /// Defines a placeholder for unimplemented failure mechanisms objects /// - public class FailureMechanismPlaceholder : PlaceholderWithReadonlyName, IFailureMechanism + public class FailureMechanismPlaceholder : BaseFailureMechanism { /// /// Initializes a new instance of the class. /// /// The placeholder's name. - public FailureMechanismPlaceholder(string name) : base(name) + public FailureMechanismPlaceholder(string name) { SectionDivisions = new InputPlaceholder(RingtoetsCommonDataResources.FailureMechanism_SectionDevisions_DisplayName); Locations = new InputPlaceholder(RingtoetsCommonDataResources.FailureMechanism_Locations_DisplayName); BoundaryConditions = new InputPlaceholder(RingtoetsCommonDataResources.FailureMechanism_BoundaryConditions_DisplayName); AssessmentResult = new OutputPlaceholder(RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName); + Name = name; } /// @@ -40,7 +41,5 @@ /// Gets the calculation results for this failure mechanism. /// public OutputPlaceholder AssessmentResult { get; private set; } - - public double Contribution { get; set; } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.Designer.cs =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -134,7 +134,7 @@ } /// - /// Looks up a localized string similar to Kan geen bijdrage item maken zonder een faalmechanisme.. + /// Looks up a localized string similar to Kan geen bijdrage element maken zonder een faalmechanisme.. /// public static string FailureMechanismContributionItem_Can_not_create_contribution_item_without_failure_mechanism { get { @@ -144,6 +144,15 @@ } /// + /// Looks up a localized string similar to De faalkansbijdrage kan alleen bepaald worden als de norm van het traject groter is dan 0.. + /// + public static string FailureMechanismContributionItem_Norm_must_be_larger_than_zero { + get { + return ResourceManager.GetString("FailureMechanismContributionItem_Norm_must_be_larger_than_zero", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Dijken - Graserosie kruin en binnentalud. /// public static string GrassErosionFailureMechanism_DisplayName { Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.resx =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.resx (.../Resources.resx) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.resx (.../Resources.resx) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -163,9 +163,12 @@ Overig - Kan geen bijdrage item maken zonder een faalmechanisme. + Kan geen bijdrage element maken zonder een faalmechanisme. Kan geen bijdrageoverzicht maken zonder faalmechanismen. + + De faalkansbijdrage kan alleen bepaald worden als de norm van het traject groter is dan 0. + \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismContributionView.Designer.cs =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismContributionView.Designer.cs (.../FailureMechanismContributionView.Designer.cs) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismContributionView.Designer.cs (.../FailureMechanismContributionView.Designer.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -73,7 +73,17 @@ 0, 0, 0}); + this.normInput.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); this.normInput.Name = "normInput"; + this.normInput.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); // // perYearLabel // @@ -92,6 +102,7 @@ // FailureMechanismContributionView // this.Controls.Add(this.tableLayoutPanel); + this.MinimumSize = new System.Drawing.Size(212, 171); this.Name = "FailureMechanismContributionView"; resources.ApplyResources(this, "$this"); ((System.ComponentModel.ISupportInitialize)(this.probabilityDistributionGrid)).EndInit(); Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismContributionView.cs =================================================================== diff -u -r40b8a20775439cde6edfcb177005e43c947886d2 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismContributionView.cs (.../FailureMechanismContributionView.cs) (revision 40b8a20775439cde6edfcb177005e43c947886d2) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismContributionView.cs (.../FailureMechanismContributionView.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -9,10 +9,18 @@ namespace Ringtoets.Integration.Forms.Views { + /// + /// View for the , from which the + /// can be updated and the and + /// can be seen in a grid. + /// public partial class FailureMechanismContributionView : UserControl, IView, IObserver { private FailureMechanismContribution data; + /// + /// Creates a new instance of . + /// public FailureMechanismContributionView() { InitializeComponent(); @@ -39,7 +47,7 @@ public void UpdateObserver() { SetNormText(); - probabilityDistributionGrid.Refresh(); + probabilityDistributionGrid.Invalidate(); } private void SetNormValue(FailureMechanismContribution value) @@ -92,7 +100,7 @@ private void NormValueChanged(object sender, EventArgs eventArgs) { - data.Norm = (int) normInput.Value; + data.Norm = Convert.ToInt32(normInput.Value); data.NotifyObservers(); } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismContributionView.resx =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismContributionView.resx (.../FailureMechanismContributionView.resx) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismContributionView.resx (.../FailureMechanismContributionView.resx) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -153,6 +153,18 @@ Top, Bottom, Left, Right + + Top, Left, Right + + + 68, 3 + + + 74, 20 + + + 0 + normInput @@ -165,6 +177,27 @@ 1 + + Top, Bottom, Left + + + NoControl + + + 148, 0 + + + 50, 26 + + + 1 + + + per jaar + + + MiddleLeft + perYearLabel @@ -225,63 +258,6 @@ 0 - - Top, Left, Right - - - 68, 3 - - - 74, 20 - - - 0 - - - normInput - - - System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel - - - 1 - - - Top, Bottom, Left - - - NoControl - - - 148, 0 - - - 50, 26 - - - 1 - - - per jaar - - - MiddleLeft - - - perYearLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel - - - 3 - True Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/AssessmentSectionBaseTest.cs =================================================================== diff -u -r6fc99be8198e5795ca4be54719dab3d1be3c6299 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/AssessmentSectionBaseTest.cs (.../AssessmentSectionBaseTest.cs) (revision 6fc99be8198e5795ca4be54719dab3d1be3c6299) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/AssessmentSectionBaseTest.cs (.../AssessmentSectionBaseTest.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -23,6 +23,7 @@ Assert.AreEqual(String.Empty, assessmentSection.Name); Assert.AreEqual("Referentielijn", assessmentSection.ReferenceLine.Name); Assert.AreEqual("HR locatiedatabase", assessmentSection.HydraulicBoundaryDatabase.Name); + Assert.IsNull(assessmentSection.FailureMechanismContribution); } private class SimpleAssessmentSection : AssessmentSectionBase { Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Contribution/FailureMechanismContributionItemTest.cs =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Contribution/FailureMechanismContributionItemTest.cs (.../FailureMechanismContributionItemTest.cs) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Contribution/FailureMechanismContributionItemTest.cs (.../FailureMechanismContributionItemTest.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -1,4 +1,5 @@ using System; +using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data; @@ -27,9 +28,7 @@ TestDelegate test = () => new FailureMechanismContributionItem(null, new Random(21).Next()); // Assert - var message = Assert.Throws(test).Message; - StringAssert.StartsWith(Resources.FailureMechanismContributionItem_Can_not_create_contribution_item_without_failure_mechanism, message); - StringAssert.EndsWith("failureMechanism", message); + TestHelper.AssertExceptionCustomMessage(test, Resources.FailureMechanismContributionItem_Can_not_create_contribution_item_without_failure_mechanism); } [Test] @@ -46,12 +45,15 @@ mockRepository.ReplayAll(); + var norm = new Random(21).Next(); + // Call - var result = new FailureMechanismContributionItem(failureMechanism, new Random(21).Next()); + var result = new FailureMechanismContributionItem(failureMechanism, norm); // Assert - Assert.AreEqual(name,result.Assessment); - Assert.AreEqual(contribution,result.Contribution); + Assert.AreEqual(name, result.Assessment); + Assert.AreEqual(contribution, result.Contribution); + Assert.AreEqual(norm, result.Norm); mockRepository.VerifyAll(); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Contribution/FailureMechanismContributionTest.cs =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Contribution/FailureMechanismContributionTest.cs (.../FailureMechanismContributionTest.cs) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Contribution/FailureMechanismContributionTest.cs (.../FailureMechanismContributionTest.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -1,6 +1,7 @@ using System; using System.Collections.ObjectModel; using System.Linq; +using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data; @@ -27,12 +28,10 @@ var random = new Random(21); // Call - TestDelegate test = () => new FailureMechanismContribution(null, random.NextDouble(), random.Next()); + TestDelegate test = () => new FailureMechanismContribution(null, random.NextDouble(), random.Next(1, 200000)); // Assert - var message = Assert.Throws(test).Message; - StringAssert.StartsWith(Resources.FailureMechanismContribution_FailureMechanismContribution_Can_not_create_FailureMechanismContribution_without_FailureMechanism_collection, message); - StringAssert.EndsWith("failureMechanisms", message); + TestHelper.AssertExceptionCustomMessage(test, Resources.FailureMechanismContribution_FailureMechanismContribution_Can_not_create_FailureMechanismContribution_without_FailureMechanism_collection); } [Test] @@ -42,48 +41,66 @@ var random = new Random(21); // Call - TestDelegate test = () => new FailureMechanismContribution(new IFailureMechanism[]{null}, random.NextDouble(), random.Next()); + TestDelegate test = () => new FailureMechanismContribution(new IFailureMechanism[] + { + null + }, random.NextDouble(), random.Next(1, 200000)); // Assert - var message = Assert.Throws(test).Message; - StringAssert.StartsWith(Resources.FailureMechanismContributionItem_Can_not_create_contribution_item_without_failure_mechanism, message); - StringAssert.EndsWith("failureMechanism", message); + TestHelper.AssertExceptionCustomMessage(test, Resources.FailureMechanismContributionItem_Can_not_create_contribution_item_without_failure_mechanism); } [Test] + [TestCase(0)] + [TestCase(-1)] + [TestCase(-200)] + public void Constructor_WithInvalidNorm_ThrowsArgumentException(int norm) + { + // Setup + var random = new Random(21); + + // Call + TestDelegate test = () => { new FailureMechanismContribution(Enumerable.Empty(), random.NextDouble(), norm); }; + + // Assert + TestHelper.AssertExceptionCustomMessage(test, Resources.FailureMechanismContributionItem_Norm_must_be_larger_than_zero); + } + + [Test] + [TestCase(0)] [TestCase(-10)] [TestCase(-1e-6)] - [TestCase(100+1e-6)] + [TestCase(100 + 1e-6)] [TestCase(150)] - public void Constructor_OtherContributionOutside0To100_ArgumentException(double contribution) + public void Constructor_OtherContributionLessOrEqualTo0OrGreaterThan100_ArgumentException(double contribution) { // Setup var random = new Random(21); // Call - TestDelegate test = () => new FailureMechanismContribution(new IFailureMechanism[] { }, contribution, random.Next()); + TestDelegate test = () => new FailureMechanismContribution(Enumerable.Empty(), contribution, random.Next(1, 200000)); // Assert - var message = Assert.Throws(test).Message; - StringAssert.StartsWith(Common.Data.Properties.Resources.FailureMechanism_Contribution_Value_should_be_in_interval_0_100, message); - StringAssert.EndsWith("value", message); + TestHelper.AssertExceptionCustomMessage(test, Common.Data.Properties.Resources.FailureMechanism_Contribution_Value_should_be_in_interval_0_100); } [Test] - public void Constructor_EmptyFailureMechanisms_OnlyOtherFailureMechanismAdded() + [TestCase(50)] + [TestCase(1e-6)] + [TestCase(100)] + public void Constructor_EmptyFailureMechanisms_OnlyOtherFailureMechanismAddedWithContributionSet(double contribution) { // Setup var random = new Random(21); - var otherContribution = (double)random.Next(0, 100); var norm = random.Next(); // Call - var result = new FailureMechanismContribution(new IFailureMechanism[] { }, otherContribution, norm); - + var result = new FailureMechanismContribution(Enumerable.Empty(), contribution, norm); + // Assert Assert.AreEqual(1, result.Distribution.Count()); - Assert.AreEqual(otherContribution, result.Distribution.ElementAt(0).Contribution); - Assert.AreEqual((norm / otherContribution) * 100, result.Distribution.ElementAt(0).ProbabilitySpace); + Assert.AreEqual(contribution, result.Distribution.ElementAt(0).Contribution); + Assert.AreEqual((norm/contribution)*100, result.Distribution.ElementAt(0).ProbabilitySpace); Assert.AreEqual(norm, result.Norm); } @@ -95,7 +112,7 @@ { // Setup var random = new Random(21); - var otherContribution = (double)random.Next(0, 100); + var otherContribution = (double) random.Next(0, 100); var failureMechanismNames = new Collection(); var failureMechanismContributions = new Collection(); @@ -120,7 +137,7 @@ failureMechanismContributions.Add(otherContribution); mockRepository.ReplayAll(); - var norm = random.Next(); + var norm = random.Next(1, 200000); // Call var result = new FailureMechanismContribution(failureMechanisms, otherContribution, norm); @@ -130,9 +147,31 @@ CollectionAssert.AreEqual(failureMechanismNames, result.Distribution.Select(d => d.Assessment)); CollectionAssert.AreEqual(failureMechanismContributions, result.Distribution.Select(d => d.Contribution)); - CollectionAssert.AreEqual(failureMechanismContributions.Select(c => (norm / c) * 100), result.Distribution.Select(d => d.ProbabilitySpace)); + CollectionAssert.AreEqual(failureMechanismContributions.Select(c => (norm/c)*100), result.Distribution.Select(d => d.ProbabilitySpace)); mockRepository.VerifyAll(); } + + [Test] + public void Norm_WhenUpdated_NormUpdatedForEachFailureMechanismContributionItem() + { + // Setup + var random = new Random(21); + var otherContribution = (double)random.Next(0, 100); + var norm = 20000; + var newNorm = 30000; + + var failureMechanism = mockRepository.Stub(); + + mockRepository.ReplayAll(); + + var failureMechanismContribution = new FailureMechanismContribution(new[] { failureMechanism }, otherContribution, norm); + + // Call + failureMechanismContribution.Norm = newNorm; + + // Assert + Assert.AreEqual(Enumerable.Repeat(newNorm,2) , failureMechanismContribution.Distribution.Select(d => d.Norm)); + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/DikeAssessmentSectionTest.cs =================================================================== diff -u -r634ad70f88ad5172298c964897aa806d918d5815 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/DikeAssessmentSectionTest.cs (.../DikeAssessmentSectionTest.cs) (revision 634ad70f88ad5172298c964897aa806d918d5815) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/DikeAssessmentSectionTest.cs (.../DikeAssessmentSectionTest.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -18,6 +18,30 @@ // Call var section = new DikeAssessmentSection(); + var pipingName = "Dijken - Piping"; + var grassErosionName = "Dijken - Graserosie kruin en binnentalud"; + var macrostailityInwardName = "Dijken - Macrostabiliteit binnenwaarts"; + var overtoppingName = "Kunstwerken - Overslag en overloop"; + var closingName = "Kunstwerken - Niet sluiten"; + var failingOfConstructionName = "Kunstwerken - Constructief falen"; + var stoneRevetmentName = "Dijken - Steenbekledingen"; + var asphaltName = "Dijken - Asfaltbekledingen"; + var grassRevetmentName = "Dijken - Grasbekledingen"; + + var contributions = new double[] { 24, 24, 4, 2, 4, 2, 4, 3, 3, 30 }; + var names = new[] { + pipingName, + grassErosionName, + macrostailityInwardName, + overtoppingName, + closingName, + failingOfConstructionName, + stoneRevetmentName, + asphaltName, + grassRevetmentName, + Resources.OtherFailureMechanism_DisplayName + }; + // Assert Assert.IsInstanceOf(section); Assert.IsInstanceOf(section); @@ -31,14 +55,14 @@ CollectionAssert.IsEmpty(section.PipingFailureMechanism.SurfaceLines); Assert.IsInstanceOf(section.PipingFailureMechanism); - Assert.AreEqual("Dijken - Graserosie kruin en binnentalud", section.GrassErosionFailureMechanism.Name); - Assert.AreEqual("Dijken - Macrostabiliteit binnenwaarts", section.MacrostabilityInwardFailureMechanism.Name); - Assert.AreEqual("Kunstwerken - Overslag en overloop", section.OvertoppingFailureMechanism.Name); - Assert.AreEqual("Kunstwerken - Niet sluiten", section.ClosingFailureMechanism.Name); - Assert.AreEqual("Kunstwerken - Constructief falen", section.FailingOfConstructionFailureMechanism.Name); - Assert.AreEqual("Dijken - Steenbekledingen", section.StoneRevetmentFailureMechanism.Name); - Assert.AreEqual("Dijken - Asfaltbekledingen", section.AsphaltRevetmentFailureMechanism.Name); - Assert.AreEqual("Dijken - Grasbekledingen", section.GrassRevetmentFailureMechanism.Name); + Assert.AreEqual(grassErosionName, section.GrassErosionFailureMechanism.Name); + Assert.AreEqual(macrostailityInwardName, section.MacrostabilityInwardFailureMechanism.Name); + Assert.AreEqual(overtoppingName, section.OvertoppingFailureMechanism.Name); + Assert.AreEqual(closingName, section.ClosingFailureMechanism.Name); + Assert.AreEqual(failingOfConstructionName, section.FailingOfConstructionFailureMechanism.Name); + Assert.AreEqual(stoneRevetmentName, section.StoneRevetmentFailureMechanism.Name); + Assert.AreEqual(asphaltName, section.AsphaltRevetmentFailureMechanism.Name); + Assert.AreEqual(grassRevetmentName, section.GrassRevetmentFailureMechanism.Name); Assert.AreEqual(24, section.PipingFailureMechanism.Contribution); Assert.AreEqual(24, section.GrassErosionFailureMechanism.Contribution); @@ -49,6 +73,10 @@ Assert.AreEqual(4, section.StoneRevetmentFailureMechanism.Contribution); Assert.AreEqual(3, section.AsphaltRevetmentFailureMechanism.Contribution); Assert.AreEqual(3, section.GrassRevetmentFailureMechanism.Contribution); + + Assert.AreEqual(contributions, section.FailureMechanismContribution.Distribution.Select(d => d.Contribution)); + Assert.AreEqual(names, section.FailureMechanismContribution.Distribution.Select(d => d.Assessment)); + Assert.AreEqual(Enumerable.Repeat(30000.0, 10), section.FailureMechanismContribution.Distribution.Select(d => d.Norm)); } [Test] @@ -89,10 +117,11 @@ } [Test] - public void FailureMechanismContribution_Always_ReturnInitializedFailureMechanismContribution() + public void FailureMechanismContribution_DefaultConstructed_FailureMechanismContributionWithItemsForFailureMechanismsAndOther() { // Setup var assessmentSection = new DikeAssessmentSection(); + var norm = 30000; // Call var contribution = assessmentSection.FailureMechanismContribution.Distribution.ToArray(); @@ -106,11 +135,13 @@ { Assert.AreEqual(failureMechanisms[i].Name, contribution[i].Assessment); Assert.AreEqual(failureMechanisms[i].Contribution, contribution[i].Contribution); - Assert.AreEqual((30000 / contribution[i].Contribution) * 100, contribution[i].ProbabilitySpace); + Assert.AreEqual(norm, contribution[i].Norm); + Assert.AreEqual((norm / contribution[i].Contribution) * 100, contribution[i].ProbabilitySpace); } Assert.AreEqual(Resources.OtherFailureMechanism_DisplayName, contribution[9].Assessment); Assert.AreEqual(30, contribution[9].Contribution); - Assert.AreEqual((30000 / contribution[9].Contribution) * 100, 100000); + Assert.AreEqual(norm, contribution[9].Norm); + Assert.AreEqual((norm / contribution[9].Contribution) * 100, 100000); } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj =================================================================== diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj (.../Ringtoets.Integration.Data.Test.csproj) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj (.../Ringtoets.Integration.Data.Test.csproj) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -65,6 +65,10 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + {d4200f43-3f72-4f42-af0a-8ced416a38ec} Ringtoets.Common.Data Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/NodePresenters/FailureMechanismContributionNodePresenterTest.cs =================================================================== diff -u -r9a163773601ac59d2e4dbdf245e074a38c21a866 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/NodePresenters/FailureMechanismContributionNodePresenterTest.cs (.../FailureMechanismContributionNodePresenterTest.cs) (revision 9a163773601ac59d2e4dbdf245e074a38c21a866) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/NodePresenters/FailureMechanismContributionNodePresenterTest.cs (.../FailureMechanismContributionNodePresenterTest.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -8,6 +8,7 @@ using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data; +using Ringtoets.Common.Forms.NodePresenters; using Ringtoets.Integration.Data.Contribution; using Ringtoets.Integration.Forms.NodePresenters; @@ -48,7 +49,7 @@ var nodePresenter = new FailureMechanismContributionNodePresenter(contextMenuBuilderProviderMock); // Assert - Assert.IsInstanceOf(nodePresenter); + Assert.IsInstanceOf>(nodePresenter); Assert.IsNull(nodePresenter.TreeView); Assert.AreEqual(typeof(FailureMechanismContribution), nodePresenter.NodeTagType); @@ -60,7 +61,7 @@ { // Setup var projectNode = mockRepository.Stub(); - var assessmentSection = mockRepository.Stub(new IFailureMechanism[] { }, 0, 0); + var assessmentSection = mockRepository.Stub(new IFailureMechanism[] { }, 1, 1); var contextMenuBuilderProviderMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); @@ -81,7 +82,7 @@ { // Setup var contextMenuBuilderProviderMock = mockRepository.StrictMock(); - var assessmentSection = mockRepository.Stub(new IFailureMechanism[] { }, 0, 0); + var assessmentSection = mockRepository.Stub(new IFailureMechanism[] { }, 1, 1); var menuBuilderMock = mockRepository.StrictMock(); var nodeMock = mockRepository.StrictMock(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismContributionViewTest.cs =================================================================== diff -u -r40b8a20775439cde6edfcb177005e43c947886d2 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismContributionViewTest.cs (.../FailureMechanismContributionViewTest.cs) (revision 40b8a20775439cde6edfcb177005e43c947886d2) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismContributionViewTest.cs (.../FailureMechanismContributionViewTest.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -15,18 +15,31 @@ { private MockRepository mockRepository; private FailureMechanismContribution distribution; + private Form testForm; + private ControlTester normTester; [SetUp] public void Setup() { mockRepository = new MockRepository(); var random = new Random(21); - var norm = random.Next(0, 200000); - var otherContribution = random.Next(0,100); + var norm = random.Next(1, 200000); + var otherContribution = random.Next(1, 100); var failureMechanism = mockRepository.Stub(); - distribution = new FailureMechanismContribution(new[] { failureMechanism }, otherContribution, norm); + distribution = new FailureMechanismContribution(new[] + { + failureMechanism + }, otherContribution, norm); + + testForm = new Form(); } + [TearDown] + public void TearDown() + { + testForm.Dispose(); + } + [Test] public void NormTextBox_Initialize_TextSetToData() { @@ -38,11 +51,12 @@ Data = distribution }; - // Call - var result = distributionView.Controls.Find("normInput", true)[0].Text; + ShowFormWithView(distributionView); // Assert - Assert.AreEqual(distribution.Norm.ToString(), result); + Assert.AreEqual(distribution.Norm.ToString(), normTester.Text); + + mockRepository.VerifyAll(); } [Test] @@ -60,24 +74,18 @@ Data = distribution }; - using (var f = new Form()) - { - f.Controls.Add(distributionView); - f.Show(); + ShowFormWithView(distributionView); - var normTester = new ControlTester("normInput"); + // Precondition + Assert.AreEqual(distribution.Norm.ToString(), normTester.Text); - // Precondition - Assert.AreEqual(distribution.Norm.ToString(), normTester.Text); + // Call + normTester.Properties.Text = 200.ToString(); - // Call - normTester.Properties.Text = 200.ToString(); + // Assert + Assert.AreEqual(200, distribution.Norm); - // Assert - Assert.AreEqual(200, distribution.Norm); - - mockRepository.VerifyAll(); - } + mockRepository.VerifyAll(); } [Test] @@ -90,8 +98,14 @@ var someMechanism = mockRepository.Stub(); - var failureMechanism = mockRepository.StrictMock(new[] { someMechanism }, random.Next(0,100), aValue); - var newFailureMechanism = mockRepository.StrictMock(new[] { someMechanism }, random.Next(0,100), expectedValue); + var failureMechanism = mockRepository.StrictMock(new[] + { + someMechanism + }, random.Next(0, 100), aValue); + var newFailureMechanism = mockRepository.StrictMock(new[] + { + someMechanism + }, random.Next(0, 100), expectedValue); mockRepository.ReplayAll(); @@ -100,32 +114,34 @@ Data = failureMechanism }; - using (var f = new Form()) - { - f.Controls.Add(distributionView); - f.Show(); + ShowFormWithView(distributionView); - var normTester = new ControlTester("normInput"); + // Precondition + Assert.AreEqual(aValue.ToString(), normTester.Properties.Text); - // Precondition - Assert.AreEqual(aValue.ToString(), normTester.Properties.Text); + // Call + distributionView.Data = newFailureMechanism; - // Call - distributionView.Data = newFailureMechanism; + // Assert + Assert.AreEqual(expectedValue.ToString(), normTester.Properties.Text); - // Assert - Assert.AreEqual(expectedValue.ToString(), normTester.Properties.Text); + // Call + failureMechanism.NotifyObservers(); - // Call - failureMechanism.NotifyObservers(); + // Assert + Assert.AreEqual(failureMechanism.Norm, aValue); + Assert.AreEqual(newFailureMechanism.Norm, expectedValue); + Assert.AreEqual(expectedValue.ToString(), normTester.Properties.Text); - // Assert - Assert.AreEqual(failureMechanism.Norm, aValue); - Assert.AreEqual(newFailureMechanism.Norm, expectedValue); - Assert.AreEqual(expectedValue.ToString(), normTester.Properties.Text); + mockRepository.VerifyAll(); + } - mockRepository.VerifyAll(); - } + private void ShowFormWithView(FailureMechanismContributionView distributionView) + { + testForm.Controls.Add(distributionView); + testForm.Show(); + + normTester = new ControlTester("normInput"); } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/AssemblyInfo.cs =================================================================== diff -u -r5600bdc79b866be64b1c51026ce5f13c1f1c9226 -r83aacc6578d82137751a7d28f691e8b3d02312f1 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision 5600bdc79b866be64b1c51026ce5f13c1f1c9226) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision 83aacc6578d82137751a7d28f691e8b3d02312f1) @@ -6,5 +6,4 @@ [assembly: AssemblyProduct("Ringtoets.Piping.Data")] [assembly: Guid("5ff8830f-c542-40f3-9f0f-64002f39b9ef")] [assembly: InternalsVisibleTo("Ringtoets.Piping.Data.Test")] -[assembly: InternalsVisibleTo("Ringtoets.Piping.Forms")] -[assembly: InternalsVisibleTo("Ringtoets.Integration.Data")] \ No newline at end of file +[assembly: InternalsVisibleTo("Ringtoets.Piping.Forms")] \ No newline at end of file