Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs =================================================================== diff -u -r57462d55e3c28e1a33178a9df0ab581321514455 -rc4aefab5abe0f2e116423cd9659cb517e3226280 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs (.../RingtoetsContextMenuBuilderTest.cs) (revision 57462d55e3c28e1a33178a9df0ab581321514455) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs (.../RingtoetsContextMenuBuilderTest.cs) (revision c4aefab5abe0f2e116423cd9659cb517e3226280) @@ -645,6 +645,157 @@ mocks.VerifyAll(); } + #region AddUpdateForeshoreProfileOfCalculationItem + + [Test] + [Combinatorial] + public void AddUpdateForeshoreProfileOfCalculationItem_ForeshoreProfileStates_ItemAddedToContextMenuAsExpected( + [Values(true, false)] bool hasForeshoreProfile, + [Values(true, false)] bool isSynchronized) + { + // Setup + var mocks = new MockRepository(); + var applicationFeatureCommands = mocks.StrictMock(); + var importCommandHandler = mocks.StrictMock(); + var exportCommandHandler = mocks.StrictMock(); + var updateCommandHandler = mocks.StrictMock(); + var viewCommands = mocks.StrictMock(); + + var calculation = mocks.StrictMock>(); + var input = mocks.StrictMock(); + + if (hasForeshoreProfile) + { + input.Expect(ci => ci.ForeshoreProfile).Return(new TestForeshoreProfile()); + input.Expect(ci => ci.IsForeshoreProfileInputSynchronized).Return(isSynchronized); + } + else + { + input.Expect(ci => ci.ForeshoreProfile).Return(null); + } + + calculation.Expect(c => c.InputParameters).Return(input).Repeat.Any(); + var inquiryHelper = mocks.StrictMock(); + mocks.ReplayAll(); + + using (var treeViewControl = new TreeViewControl()) + { + var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommands, + importCommandHandler, + exportCommandHandler, + updateCommandHandler, + viewCommands, + calculation, + treeViewControl); + + var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder); + + // Call + ContextMenuStrip result = ringtoetsContextMenuBuilder.AddUpdateForeshoreProfileOfCalculationItem( + calculation, + inquiryHelper, + c => {}).Build(); + + // Assert + Assert.IsInstanceOf(result); + Assert.AreEqual(1, result.Items.Count); + + string tooltip; + if (hasForeshoreProfile) + { + tooltip = isSynchronized + ? "Er zijn geen wijzigingen om bij te werken." + : "Berekening bijwerken met het voorlandprofiel."; + } + else + { + tooltip = "Er moet een voorlandprofiel geselecteerd zijn."; + } + + TestHelper.AssertContextMenuStripContainsItem(result, 0, + "&Bijwerken voorlandprofiel...", + tooltip, + RingtoetsFormsResources.UpdateItemIcon, + hasForeshoreProfile && !isSynchronized); + } + + mocks.VerifyAll(); + } + + #endregion + + #region AddUpdateForeshoreProfileOfCalculationsItem + + [Test] + [Combinatorial] + public void AddUpdateForeshoreProfileOfCalculationsItem_ForeshoreProfileStates_ItemAddedToContextMenuAsExpected( + [Values(true, false)] bool hasForeshoreProfile, + [Values(true, false)] bool isSynchronized) + { + // Setup + var mocks = new MockRepository(); + var applicationFeatureCommands = mocks.StrictMock(); + var importCommandHandler = mocks.StrictMock(); + var exportCommandHandler = mocks.StrictMock(); + var updateCommandHandler = mocks.StrictMock(); + var viewCommands = mocks.StrictMock(); + + var calculation = mocks.StrictMock>(); + var input = mocks.StrictMock(); + if (hasForeshoreProfile) + { + input.Expect(ci => ci.ForeshoreProfile).Return(new TestForeshoreProfile()); + input.Expect(ci => ci.IsForeshoreProfileInputSynchronized).Return(isSynchronized); + } + else + { + input.Expect(ci => ci.ForeshoreProfile).Return(null); + } + calculation.Stub(c => c.InputParameters).Return(input); + var inquiryHelper = mocks.StrictMock(); + mocks.ReplayAll(); + + using (var treeViewControl = new TreeViewControl()) + { + var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommands, + importCommandHandler, + exportCommandHandler, + updateCommandHandler, + viewCommands, + calculation, + treeViewControl); + + var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder); + + // Call + ContextMenuStrip result = ringtoetsContextMenuBuilder.AddUpdateForeshoreProfileOfCalculationsItem( + new[] + { + calculation + }, + inquiryHelper, + c => {}).Build(); + + // Assert + Assert.IsInstanceOf(result); + Assert.AreEqual(1, result.Items.Count); + + string tooltip = hasForeshoreProfile && !isSynchronized + ? "Alle berekeningen met een voorlandprofiel bijwerken." + : "Er zijn geen berekeningen om bij te werken."; + + TestHelper.AssertContextMenuStripContainsItem(result, 0, + "&Bijwerken voorlandprofielen...", + tooltip, + RingtoetsFormsResources.UpdateItemIcon, + hasForeshoreProfile && !isSynchronized); + } + + mocks.VerifyAll(); + } + + #endregion + #region AddPerformCalculationItem [Test] @@ -1617,242 +1768,6 @@ #endregion - #region AddUpdateForeshoreProfileOfCalculationItem - - [Test] - [TestCase(true)] - [TestCase(false)] - public void AddUpdateForeshoreProfileOfCalculationItem_CalculationWithForeshoreProfile_ItemAddedToContextMenuEnabledIfNotSynchronized( - bool synchronized) - { - // Setup - var mocks = new MockRepository(); - var applicationFeatureCommands = mocks.StrictMock(); - var importCommandHandler = mocks.StrictMock(); - var exportCommandHandler = mocks.StrictMock(); - var updateCommandHandler = mocks.StrictMock(); - var viewCommands = mocks.StrictMock(); - - var calculation = mocks.StrictMock>(); - var input = mocks.StrictMock(); - input.Expect(i => i.ForeshoreProfile).Return(new TestForeshoreProfile()); - input.Expect(i => i.IsForeshoreProfileInputSynchronized).Return(synchronized); - calculation.Expect(c => c.InputParameters).Return(input).Repeat.Any(); - var inquiryHelper = mocks.StrictMock(); - mocks.ReplayAll(); - - using (var treeViewControl = new TreeViewControl()) - { - var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommands, - importCommandHandler, - exportCommandHandler, - updateCommandHandler, - viewCommands, - calculation, - treeViewControl); - - var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder); - - // Call - ContextMenuStrip result = ringtoetsContextMenuBuilder.AddUpdateForeshoreProfileOfCalculationItem( - calculation, - inquiryHelper, - c => {}).Build(); - - // Assert - Assert.IsInstanceOf(result); - Assert.AreEqual(1, result.Items.Count); - TestHelper.AssertContextMenuStripContainsItem(result, 0, - "&Bijwerken voorlandprofiel...", - synchronized - ? "Er zijn geen wijzigingen om bij te werken." - : "Berekening bijwerken met het voorlandprofiel.", - RingtoetsFormsResources.UpdateItemIcon, - !synchronized); - } - - mocks.VerifyAll(); - } - - [Test] - public void AddUpdateForeshoreProfileOfCalculationItem_CalculationWithoutForeshoreProfile_ItemAddedToContextMenuDisabled() - { - // Setup - var mocks = new MockRepository(); - var applicationFeatureCommands = mocks.StrictMock(); - var importCommandHandler = mocks.StrictMock(); - var exportCommandHandler = mocks.StrictMock(); - var updateCommandHandler = mocks.StrictMock(); - var viewCommands = mocks.StrictMock(); - - var calculation = mocks.StrictMock>(); - calculation.Expect(c => c.InputParameters.ForeshoreProfile).Return(null); - var inquiryHelper = mocks.StrictMock(); - mocks.ReplayAll(); - - using (var treeViewControl = new TreeViewControl()) - { - var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommands, - importCommandHandler, - exportCommandHandler, - updateCommandHandler, - viewCommands, - calculation, - treeViewControl); - - var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder); - - // Call - ContextMenuStrip result = ringtoetsContextMenuBuilder.AddUpdateForeshoreProfileOfCalculationItem( - calculation, - inquiryHelper, - c => {}).Build(); - - // Assert - Assert.IsInstanceOf(result); - Assert.AreEqual(1, result.Items.Count); - TestHelper.AssertContextMenuStripContainsItem(result, 0, - "&Bijwerken voorlandprofiel...", - "Er moet een voorlandprofiel geselecteerd zijn.", - RingtoetsFormsResources.UpdateItemIcon, - false); - } - - mocks.VerifyAll(); - } - - #endregion - - #region AddUpdateForeshoreProfileOfCalculationsItem - - [Test] - [TestCase(true)] - [TestCase(false)] - public void AddUpdateForeshoreProfileOfCalculationsItem_CalculationWithForeshoreProfile_ItemAddedToContextMenuEnabledIfNotSynchronized( - bool synchronized) - { - // Setup - var mocks = new MockRepository(); - var applicationFeatureCommands = mocks.StrictMock(); - var importCommandHandler = mocks.StrictMock(); - var exportCommandHandler = mocks.StrictMock(); - var updateCommandHandler = mocks.StrictMock(); - var viewCommands = mocks.StrictMock(); - - var calculation = mocks.StrictMock>(); - var input = mocks.StrictMock(); - input.Expect(i => i.ForeshoreProfile).Return(new TestForeshoreProfile()); - input.Expect(i => i.IsForeshoreProfileInputSynchronized).Return(synchronized); - calculation.Stub(c => c.InputParameters).Return(input); - - var calculationWithoutChanges = mocks.StrictMock>(); - var inputWithoutChanges = mocks.StrictMock(); - inputWithoutChanges.Stub(ci => ci.ForeshoreProfile).Return(new TestForeshoreProfile()); - inputWithoutChanges.Stub(ci => ci.IsForeshoreProfileInputSynchronized).Return(true); - calculationWithoutChanges.Stub(c => c.InputParameters).Return(inputWithoutChanges); - - var inquiryHelper = mocks.StrictMock(); - mocks.ReplayAll(); - - using (var treeViewControl = new TreeViewControl()) - { - var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommands, - importCommandHandler, - exportCommandHandler, - updateCommandHandler, - viewCommands, - calculation, - treeViewControl); - - var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder); - - // Call - ContextMenuStrip result = ringtoetsContextMenuBuilder.AddUpdateForeshoreProfileOfCalculationsItem( - new[] - { - calculation, - calculationWithoutChanges - }, - inquiryHelper, - c => {}).Build(); - - // Assert - Assert.IsInstanceOf(result); - Assert.AreEqual(1, result.Items.Count); - TestHelper.AssertContextMenuStripContainsItem(result, 0, - "&Bijwerken voorlandprofielen...", - synchronized - ? "Er zijn geen berekeningen om bij te werken." - : "Alle berekeningen met een voorlandprofiel bijwerken.", - RingtoetsFormsResources.UpdateItemIcon, - !synchronized); - } - - mocks.VerifyAll(); - } - - [Test] - public void AddUpdateForeshoreProfileOfCalculationsItem_CalculationWithoutForeshoreProfile_ItemAddedToContextMenuDisabled() - { - // Setup - var mocks = new MockRepository(); - var applicationFeatureCommands = mocks.StrictMock(); - var importCommandHandler = mocks.StrictMock(); - var exportCommandHandler = mocks.StrictMock(); - var updateCommandHandler = mocks.StrictMock(); - var viewCommands = mocks.StrictMock(); - - var calculation = mocks.StrictMock>(); - var input = mocks.StrictMock(); - input.Expect(i => i.ForeshoreProfile).Return(null); - calculation.Expect(c => c.InputParameters).Return(input); - - var calculationWithoutChanges = mocks.StrictMock>(); - var inputWithoutChanges = mocks.StrictMock(); - inputWithoutChanges.Stub(ci => ci.ForeshoreProfile).Return(new TestForeshoreProfile()); - inputWithoutChanges.Stub(ci => ci.IsForeshoreProfileInputSynchronized).Return(true); - calculationWithoutChanges.Stub(c => c.InputParameters).Return(inputWithoutChanges); - - var inquiryHelper = mocks.StrictMock(); - mocks.ReplayAll(); - - using (var treeViewControl = new TreeViewControl()) - { - var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommands, - importCommandHandler, - exportCommandHandler, - updateCommandHandler, - viewCommands, - calculation, - treeViewControl); - - var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder); - - // Call - ContextMenuStrip result = ringtoetsContextMenuBuilder.AddUpdateForeshoreProfileOfCalculationsItem( - new[] - { - calculation, - calculationWithoutChanges - }, - inquiryHelper, - c => {}).Build(); - - // Assert - Assert.IsInstanceOf(result); - Assert.AreEqual(1, result.Items.Count); - TestHelper.AssertContextMenuStripContainsItem(result, 0, - "&Bijwerken voorlandprofielen...", - "Er zijn geen berekeningen om bij te werken.", - RingtoetsFormsResources.UpdateItemIcon, - false); - } - - mocks.VerifyAll(); - } - - #endregion - #region Nested types private class TestFailureMechanismContext : FailureMechanismContext Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs =================================================================== diff -u -r5b29217fb2099ab005ad86d9f53dbd8369210372 -rc4aefab5abe0f2e116423cd9659cb517e3226280 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision 5b29217fb2099ab005ad86d9f53dbd8369210372) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision c4aefab5abe0f2e116423cd9659cb517e3226280) @@ -318,7 +318,8 @@ "IsForeshoreProfileInputSynchronized", "ReturnFalse" })] - public void IsForeshoreProfileInputSynchronized_ForeshoreProfileAndInputNotInSync_ReturnFalse(ForeshoreProfile modifiedProfile) + public void IsForeshoreProfileInputSynchronized_ForeshoreProfileAndInputNotInSync_ReturnFalse( + ForeshoreProfile modifiedProfile) { // Setup var input = new WaveConditionsInput @@ -354,7 +355,7 @@ input.SynchronizeForeshoreProfileInput(); // Assert - AssertWaveConditionsInput(null, input); + AssertForeshoreProfileInputProperties(null, input); } [Test] @@ -381,13 +382,13 @@ input.ForeshoreProfile.CopyProperties(differentProfile); // Precondition - AssertWaveConditionsInput(new TestForeshoreProfile(), input); + AssertForeshoreProfileInputProperties(new TestForeshoreProfile(), input); // Call input.SynchronizeForeshoreProfileInput(); // Assert - AssertWaveConditionsInput(differentProfile, input); + AssertForeshoreProfileInputProperties(differentProfile, input); } [Test] @@ -426,7 +427,8 @@ TestDelegate call = () => input.Orientation = (RoundedDouble) invalidValue; // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "De waarde voor de oriƫntatie moet in het bereik [0,00, 360,00] liggen."); + const string message = "De waarde voor de oriƫntatie moet in het bereik [0,00, 360,00] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, message); } [Test] @@ -494,7 +496,9 @@ [TestCase(4.0, double.NaN)] [TestCase(double.NaN, 5.0)] [TestCase(double.NaN, double.NaN)] - public void LowerBoundaryRevetment_ValidValueAccordingtoUpperBoundaryRevetment_ValueIsSet(double lowerBoundaryRevetment, double upperBoundaryRevetment) + public void LowerBoundaryRevetment_ValidValueAccordingtoUpperBoundaryRevetment_ValueIsSet( + double lowerBoundaryRevetment, + double upperBoundaryRevetment) { // Setup var input = new WaveConditionsInput @@ -513,7 +517,9 @@ [TestCase(5.0, 4.0)] [TestCase(4.0, 4.0)] [TestCase(3.995, 4.0)] - public void LowerBoundaryRevetment_InvalidValueAccordingtoUpperBoundaryRevetment_ThrowsArgumentOutOfRangeException(double lowerBoundaryRevetment, double upperBoundaryRevetment) + public void LowerBoundaryRevetment_InvalidValueAccordingtoUpperBoundaryRevetment_ThrowsArgumentOutOfRangeException( + double lowerBoundaryRevetment, + double upperBoundaryRevetment) { // Setup var input = new WaveConditionsInput @@ -525,7 +531,7 @@ TestDelegate test = () => input.LowerBoundaryRevetment = (RoundedDouble) lowerBoundaryRevetment; // Assert - var expectedMessage = "De bovengrens van de bekleding moet boven de ondergrens liggen."; + const string expectedMessage = "De bovengrens van de bekleding moet boven de ondergrens liggen."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } @@ -566,7 +572,9 @@ [TestCase(4.0, double.NaN)] [TestCase(double.NaN, 5.0)] [TestCase(double.NaN, double.NaN)] - public void UpperBoundaryRevetment_ValidValueAccordingtoLowerBoundaryRevetment_ValueIsSet(double lowerBoundaryRevetment, double upperBoundaryRevetment) + public void UpperBoundaryRevetment_ValidValueAccordingtoLowerBoundaryRevetment_ValueIsSet( + double lowerBoundaryRevetment, + double upperBoundaryRevetment) { // Setup var input = new WaveConditionsInput @@ -585,7 +593,9 @@ [TestCase(4.0, 3.0)] [TestCase(4.0, 4.0)] [TestCase(4.0, 4.004)] - public void UpperBoundaryRevetment_InvalidValueAccordingtoLowerBoundaryRevetment_ThrowsArgumentOutOfRangeException(double lowerBoundaryRevetment, double upperBoundaryRevetment) + public void UpperBoundaryRevetment_InvalidValueAccordingtoLowerBoundaryRevetment_ThrowsArgumentOutOfRangeException( + double lowerBoundaryRevetment, + double upperBoundaryRevetment) { // Setup var input = new WaveConditionsInput @@ -638,7 +648,9 @@ [TestCase(4.0, double.NaN)] [TestCase(double.NaN, 5.0)] [TestCase(double.NaN, double.NaN)] - public void LowerBoundaryWaterLevels_ValidValueAccordingtoUpperBoundaryWaterLevels_ValueIsSet(double lowerBoundaryWaterLevels, double upperBoundaryWaterLevels) + public void LowerBoundaryWaterLevels_ValidValueAccordingtoUpperBoundaryWaterLevels_ValueIsSet( + double lowerBoundaryWaterLevels, + double upperBoundaryWaterLevels) { // Setup var input = new WaveConditionsInput @@ -657,7 +669,9 @@ [TestCase(5.0, 4.0)] [TestCase(4.0, 4.0)] [TestCase(3.995, 4.0)] - public void LowerBoundaryWaterLevels_InvalidValueAccordingtoUpperBoundaryWaterLevels_ThrowsArgumentOutOfRangeException(double lowerBoundaryWaterLevels, double upperBoundaryWaterLevels) + public void LowerBoundaryWaterLevels_InvalidValueAccordingtoUpperBoundaryWaterLevels_ThrowsArgumentOutOfRangeException( + double lowerBoundaryWaterLevels, + double upperBoundaryWaterLevels) { // Setup var input = new WaveConditionsInput @@ -710,7 +724,9 @@ [TestCase(4.0, double.NaN)] [TestCase(double.NaN, 5.0)] [TestCase(double.NaN, double.NaN)] - public void UpperBoundaryWaterLevels_ValidValueAccordingtoLowerBoundaryWaterLevels_ValueIsSet(double lowerBoundaryWaterLevels, double upperBoundaryWaterLevels) + public void UpperBoundaryWaterLevels_ValidValueAccordingtoLowerBoundaryWaterLevels_ValueIsSet( + double lowerBoundaryWaterLevels, + double upperBoundaryWaterLevels) { // Setup var input = new WaveConditionsInput @@ -729,7 +745,9 @@ [TestCase(4.0, 3.0)] [TestCase(4.0, 4.0)] [TestCase(4.0, 4.004)] - public void UpperBoundaryWaterLevels_InvalidValueAccordingtoLowerBoundaryWaterLevels_ThrowsArgumentOutOfRangeException(double lowerBoundaryWaterLevels, double upperBoundaryWaterLevels) + public void UpperBoundaryWaterLevels_InvalidValueAccordingtoLowerBoundaryWaterLevels_ThrowsArgumentOutOfRangeException( + double lowerBoundaryWaterLevels, + double upperBoundaryWaterLevels) { // Setup var input = new WaveConditionsInput @@ -764,7 +782,9 @@ [TestCase(double.NaN, 10.0, 12.0)] [TestCase(1.0, double.NaN, 12.0)] [TestCase(1.0, 10.0, double.NaN)] - public void WaterLevels_InvalidInput_NoWaterLevels(double lowerBoundaryRevetments, double upperBoundaryRevetments, double designWaterLevel) + public void WaterLevels_InvalidInput_NoWaterLevels(double lowerBoundaryRevetments, + double upperBoundaryRevetments, + double designWaterLevel) { // Setup var input = new WaveConditionsInput @@ -833,9 +853,13 @@ [Test] [TestCaseSource(nameof(WaterLevels))] - public void WaterLevels_ValidInput_ReturnsWaterLevels(WaveConditionsInputStepSize stepSize, double lowerBoundaryRevetment, double upperBoundaryRevetment, - double lowerBoundaryWaterLevels, double upperBoundaryWaterLevels, - double designWaterLevel, IEnumerable expectedWaterLevels) + public void WaterLevels_ValidInput_ReturnsWaterLevels(WaveConditionsInputStepSize stepSize, + double lowerBoundaryRevetment, + double upperBoundaryRevetment, + double lowerBoundaryWaterLevels, + double upperBoundaryWaterLevels, + double designWaterLevel, + IEnumerable expectedWaterLevels) { // Setup var input = new WaveConditionsInput @@ -858,7 +882,8 @@ CollectionAssert.AreEqual(expectedWaterLevels, waterLevels); } - private static void AssertWaveConditionsInput(ForeshoreProfile expectedForeshoreProfile, WaveConditionsInput input) + private static void AssertForeshoreProfileInputProperties(ForeshoreProfile expectedForeshoreProfile, + WaveConditionsInput input) { var defaultInput = new WaveConditionsInput(); if (expectedForeshoreProfile == null)