Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/HydraulicBoundaryLocationUpdateExtensionsTest.cs =================================================================== diff -u -r61ced0f990b10b560e2d5700b5851cdb188585db -r6fc38f8582161da49669e8785efa98ad32cc02ae --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/HydraulicBoundaryLocationUpdateExtensionsTest.cs (.../HydraulicBoundaryLocationUpdateExtensionsTest.cs) (revision 61ced0f990b10b560e2d5700b5851cdb188585db) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/HydraulicBoundaryLocationUpdateExtensionsTest.cs (.../HydraulicBoundaryLocationUpdateExtensionsTest.cs) (revision 6fc38f8582161da49669e8785efa98ad32cc02ae) @@ -134,8 +134,8 @@ double newY = random.NextDouble() * 10; long newId = 2; string newName = "newName"; - double newDesignWaterLevel = random.NextDouble() * 10; - double newWaveHeight = random.NextDouble() * 10; + double newDesignWaterLevel = random.NextDouble(); + double newWaveHeight = random.NextDouble(); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(newId, newName, newX, newY) { Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Data.Test/HydraulicBoundaryLocationTest.cs =================================================================== diff -u -r27d670bb56639222f0faddadeeda390e855a7079 -r6fc38f8582161da49669e8785efa98ad32cc02ae --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Data.Test/HydraulicBoundaryLocationTest.cs (.../HydraulicBoundaryLocationTest.cs) (revision 27d670bb56639222f0faddadeeda390e855a7079) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Data.Test/HydraulicBoundaryLocationTest.cs (.../HydraulicBoundaryLocationTest.cs) (revision 6fc38f8582161da49669e8785efa98ad32cc02ae) @@ -65,23 +65,6 @@ } [Test] - public void Properties_ValidParameters_PropertiesAsExpected() - { - // Setup - const double designWaterLevel = 741.0; - const double waveHeight = 132.0; - HydraulicBoundaryLocation hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "", 0, 0); - - // Call - hydraulicBoundaryLocation.DesignWaterLevel = designWaterLevel; - hydraulicBoundaryLocation.WaveHeight = waveHeight; - - // Assert - Assert.AreEqual(designWaterLevel, hydraulicBoundaryLocation.DesignWaterLevel); - Assert.AreEqual(waveHeight, hydraulicBoundaryLocation.WaveHeight); - } - - [Test] public void ToString_Always_ReturnsName() { // Setup Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelContextTreeNodeInfoTest.cs =================================================================== diff -u -r0ac7450f53970c5742d115164a02e2304c0ce9d3 -r6fc38f8582161da49669e8785efa98ad32cc02ae --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelContextTreeNodeInfoTest.cs (.../DesignWaterLevelContextTreeNodeInfoTest.cs) (revision 0ac7450f53970c5742d115164a02e2304c0ce9d3) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelContextTreeNodeInfoTest.cs (.../DesignWaterLevelContextTreeNodeInfoTest.cs) (revision 6fc38f8582161da49669e8785efa98ad32cc02ae) @@ -22,6 +22,7 @@ using System; using System.Drawing; using System.Linq; +using System.Windows.Forms; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; @@ -42,12 +43,12 @@ [TestFixture] public class DesignWaterLevelContextTreeNodeInfoTest : NUnitFormTest { - private MockRepository mocks; + private MockRepository mockRepository; [SetUp] public void SetUp() { - mocks = new MockRepository(); + mockRepository = new MockRepository(); } [Test] @@ -82,7 +83,7 @@ // Setup using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); // Call var text = info.Text(null); @@ -98,7 +99,7 @@ // Setup using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); // Call var image = info.Image(null); @@ -112,9 +113,9 @@ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup - var guiMock = mocks.StrictMock(); - var menuBuilderMock = mocks.StrictMock(); - var assessmentSectionMock = mocks.Stub(); + var guiMock = mockRepository.StrictMock(); + var menuBuilderMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); var nodeData = new DesignWaterLevelContext(assessmentSectionMock); @@ -129,11 +130,11 @@ { guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilderMock); - mocks.ReplayAll(); + mockRepository.ReplayAll(); using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); plugin.Gui = guiMock; @@ -142,15 +143,15 @@ } } // Assert - mocks.VerifyAll(); + mockRepository.VerifyAll(); } [Test] public void ContextMenuStrip_NoHydraulicBoundaryDatabaseSet_ContextMenuItemBerekenenDisabled() { // Setup - var guiMock = mocks.StrictMock(); - var assessmentSectionMock = mocks.Stub(); + var guiMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); var nodeData = new DesignWaterLevelContext(assessmentSectionMock); @@ -160,16 +161,16 @@ using (var treeViewControl = new TreeViewControl()) { guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - mocks.ReplayAll(); + mockRepository.ReplayAll(); using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); plugin.Gui = guiMock; // Call - var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl); + ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl); // Assert const string expectedItemText = "&Berekenen"; @@ -179,15 +180,15 @@ } } - mocks.VerifyAll(); // Expect no calls on arguments + mockRepository.VerifyAll(); // Expect no calls on arguments } [Test] public void ContextMenuStrip_HydraulicBoundaryDatabaseSet_ContextMenuItemBerekenenEnabled() { // Setup - var guiMock = mocks.StrictMock(); - var assessmentSectionMock = mocks.Stub(); + var guiMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); var nodeData = new DesignWaterLevelContext(assessmentSectionMock); nodeData.WrappedData.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); @@ -197,16 +198,16 @@ using (var treeViewControl = new TreeViewControl()) { guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - mocks.ReplayAll(); + mockRepository.ReplayAll(); using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); plugin.Gui = guiMock; // Call - var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl); + ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl); // Assert const string expectedItemText = "&Berekenen"; @@ -216,15 +217,14 @@ } } - mocks.VerifyAll(); // Expect no calls on arguments + mockRepository.VerifyAll(); // Expect no calls on arguments } [Test] public void GivenHydraulicBoundaryDatabaseWithNonExistingFilePath_WhenCalculatingAssessmentLevelFromContextMenu_ThenLogMessagesAddedPreviousOutputNotAffected() { // Given - var gui = mocks.DynamicMock(); - + var guiMock = mockRepository.DynamicMock(); var contextMenuRunAssessmentLevelCalculationsIndex = 0; var hydraulicBoundaryLocation1 = new HydraulicBoundaryLocation(100001, "", 1.1, 2.2); @@ -252,16 +252,16 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Expect(cmp => cmp.Get(designWaterLevelContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + guiMock.Expect(cmp => cmp.Get(designWaterLevelContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - mocks.ReplayAll(); + mockRepository.ReplayAll(); using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); - plugin.Gui = gui; + TreeNodeInfo info = GetInfo(plugin); + plugin.Gui = guiMock; - var contextMenuAdapter = info.ContextMenuStrip(designWaterLevelContext, null, treeViewControl); + ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(designWaterLevelContext, null, treeViewControl); // When Action action = () => { contextMenuAdapter.Items[contextMenuRunAssessmentLevelCalculationsIndex].PerformClick(); }; @@ -275,83 +275,83 @@ Assert.AreEqual(4.2, hydraulicBoundaryLocation2.DesignWaterLevel); // Previous result not cleared } } - mocks.VerifyAll(); + mockRepository.VerifyAll(); } [Test] public void ForeColor_ContextHasNoHydraulicBoundaryDatabase_ReturnDisabledColor() { // Setup - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); - var designWaterLevelContext = new DesignWaterLevelContext(assessmentSection); + var designWaterLevelContext = new DesignWaterLevelContext(assessmentSectionMock); using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); // Call Color color = info.ForeColor(designWaterLevelContext); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); } - mocks.VerifyAll(); + mockRepository.VerifyAll(); } [Test] public void ForeColor_ContextHasNoCalculations_ReturnControlColor() { // Setup - var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - mocks.ReplayAll(); + var assessmentSectionMock = mockRepository.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + mockRepository.ReplayAll(); - var designWaterLevelContext = new DesignWaterLevelContext(assessmentSection); + var designWaterLevelContext = new DesignWaterLevelContext(assessmentSectionMock); using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); // Call Color color = info.ForeColor(designWaterLevelContext); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); } - mocks.VerifyAll(); + mockRepository.VerifyAll(); } [Test] public void ForeColor_ContextHasCalculations_ReturnControlColor() { // Setup - var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var assessmentSectionMock = mockRepository.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var location = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) { DesignWaterLevel = 1.0 }; - assessmentSection.HydraulicBoundaryDatabase.Locations.Add(location); - mocks.ReplayAll(); + assessmentSectionMock.HydraulicBoundaryDatabase.Locations.Add(location); + mockRepository.ReplayAll(); - var designWaterLevelContext = new DesignWaterLevelContext(assessmentSection); + var designWaterLevelContext = new DesignWaterLevelContext(assessmentSectionMock); using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); // Call Color color = info.ForeColor(designWaterLevelContext); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); } - mocks.VerifyAll(); + mockRepository.VerifyAll(); } - private TreeNodeInfo GetInfo(RingtoetsPlugin plugin) + private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin) { return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(DesignWaterLevelContext)); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/WaveHeightContextTreeNodeInfoTest.cs =================================================================== diff -u -r0ac7450f53970c5742d115164a02e2304c0ce9d3 -r6fc38f8582161da49669e8785efa98ad32cc02ae --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/WaveHeightContextTreeNodeInfoTest.cs (.../WaveHeightContextTreeNodeInfoTest.cs) (revision 0ac7450f53970c5742d115164a02e2304c0ce9d3) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/WaveHeightContextTreeNodeInfoTest.cs (.../WaveHeightContextTreeNodeInfoTest.cs) (revision 6fc38f8582161da49669e8785efa98ad32cc02ae) @@ -22,6 +22,7 @@ using System; using System.Drawing; using System.Linq; +using System.Windows.Forms; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; @@ -55,7 +56,7 @@ // Setup using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); // Assert Assert.AreEqual(typeof(WaveHeightContext), info.TagType); @@ -81,10 +82,10 @@ // Setup using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); // Call - var text = info.Text(null); + string text = info.Text(null); // Assert const string expectedName = "Golfhoogtes"; @@ -98,10 +99,10 @@ // Setup using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); // Call - var image = info.Image(null); + Image image = info.Image(null); // Assert TestHelper.AssertImagesAreEqual(Resources.GenericInputOutputIcon, image); @@ -133,7 +134,7 @@ using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); plugin.Gui = guiMock; @@ -164,7 +165,7 @@ using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); plugin.Gui = guiMock; @@ -205,12 +206,12 @@ using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); plugin.Gui = guiMock; // Call - var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl); + ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl); // Assert const string expectedItemText = "&Berekenen"; @@ -227,17 +228,17 @@ public void ForeColor_ContextHasNoHydraulicBoundaryDatabase_ReturnDisabledColor() { // Setup - var assessmentSection = mockRepository.Stub(); + var assessmentSectionMock = mockRepository.Stub(); mockRepository.ReplayAll(); - var waterLevelContext = new WaveHeightContext(assessmentSection); + var waveHeightContext = new WaveHeightContext(assessmentSectionMock); using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); // Call - Color color = info.ForeColor(waterLevelContext); + Color color = info.ForeColor(waveHeightContext); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); @@ -249,18 +250,18 @@ public void ForeColor_ContextHasNoCalculations_ReturnControlColor() { // Setup - var assessmentSection = mockRepository.Stub(); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var assessmentSectionMock = mockRepository.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); mockRepository.ReplayAll(); - var waterLevelContext = new WaveHeightContext(assessmentSection); + var waveHeightContext = new WaveHeightContext(assessmentSectionMock); using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); // Call - Color color = info.ForeColor(waterLevelContext); + Color color = info.ForeColor(waveHeightContext); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); @@ -272,23 +273,23 @@ public void ForeColor_ContextHasCalculations_ReturnControlColor() { // Setup - var assessmentSection = mockRepository.Stub(); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var assessmentSectionMock = mockRepository.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var location = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) { WaveHeight = 1.0 }; - assessmentSection.HydraulicBoundaryDatabase.Locations.Add(location); + assessmentSectionMock.HydraulicBoundaryDatabase.Locations.Add(location); mockRepository.ReplayAll(); - var waterLevelContext = new WaveHeightContext(assessmentSection); + var waveHeightContext = new WaveHeightContext(assessmentSectionMock); using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); + TreeNodeInfo info = GetInfo(plugin); // Call - Color color = info.ForeColor(waterLevelContext); + Color color = info.ForeColor(waveHeightContext); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); @@ -297,12 +298,12 @@ } [Test] - public void GivenHydraulicBoundaryDatabaseWithNonExistingFilePath_WhenCalculatingAssessmentLevelFromContextMenu_ThenLogMessagesAddedPreviousOutputNotAffected() + public void GivenHydraulicBoundaryDatabaseWithNonExistingFilePath_WhenCalculatingWaveHeightFromContextMenu_ThenLogMessagesAddedPreviousOutputNotAffected() { // Given - var gui = mockRepository.DynamicMock(); + var guiMock = mockRepository.DynamicMock(); - var contextMenuRunAssessmentLevelCalculationsIndex = 0; + var contextMenuRunWaveHeightCalculationsIndex = 0; var hydraulicBoundaryLocation1 = new HydraulicBoundaryLocation(100001, "", 1.1, 2.2); var hydraulicBoundaryLocation2 = new HydraulicBoundaryLocation(100002, "", 3.3, 4.4) @@ -329,19 +330,19 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Expect(cmp => cmp.Get(waveHeightContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + guiMock.Expect(cmp => cmp.Get(waveHeightContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); mockRepository.ReplayAll(); using (var plugin = new RingtoetsPlugin()) { - var info = GetInfo(plugin); - plugin.Gui = gui; + TreeNodeInfo info = GetInfo(plugin); + plugin.Gui = guiMock; - var contextMenuAdapter = info.ContextMenuStrip(waveHeightContext, null, treeViewControl); + ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(waveHeightContext, null, treeViewControl); // When - Action action = () => { contextMenuAdapter.Items[contextMenuRunAssessmentLevelCalculationsIndex].PerformClick(); }; + Action action = () => { contextMenuAdapter.Items[contextMenuRunWaveHeightCalculationsIndex].PerformClick(); }; // Then string message = string.Format("Berekeningen konden niet worden gestart. Fout bij het lezen van bestand '{0}': Het bestand bestaat niet.", Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/DesignWaterLevelCalculationActivityTest.cs =================================================================== diff -u -ra2f070e495d1ac6307fe0267d58aade65f35a5d8 -r6fc38f8582161da49669e8785efa98ad32cc02ae --- Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/DesignWaterLevelCalculationActivityTest.cs (.../DesignWaterLevelCalculationActivityTest.cs) (revision a2f070e495d1ac6307fe0267d58aade65f35a5d8) +++ Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/DesignWaterLevelCalculationActivityTest.cs (.../DesignWaterLevelCalculationActivityTest.cs) (revision 6fc38f8582161da49669e8785efa98ad32cc02ae) @@ -28,6 +28,8 @@ using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Contribution; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; using Ringtoets.Integration.Plugin.FileImporters; @@ -92,22 +94,23 @@ // Assert var exception = Assert.Throws(call); Assert.AreEqual("hydraulicBoundaryLocation", exception.ParamName); + mocks.VerifyAll(); } [Test] public void Run_InvalidHydraulicBoundaryDatabase_PerformValidationAndLogStartAndEndAndError() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + var mockRepository = new MockRepository(); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { - HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - FilePath = Path.Combine(testDataPath, "notexisting.sqlite") - } + FilePath = Path.Combine(testDataPath, "notexisting.sqlite") }; + mockRepository.ReplayAll(); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 0, 0); - var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + var activity = new DesignWaterLevelCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); // Call Action call = () => activity.Run(); @@ -123,19 +126,27 @@ StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculationName), msgs[2]); }); Assert.AreEqual(ActivityState.Failed, activity.State); + mockRepository.VerifyAll(); } [Test] public void Run_ValidHydraulicBoundaryDatabaseAndHydraulicBoundaryLocation_PerformValidationAndCalculationAndLogStartAndEnd() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); + var mockRepository = new MockRepository(); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.Expect(o => o.NotifyObservers()); - var hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(loc => loc.Id == 1300001); + var failureMechanismContribution = new FailureMechanismContribution(Enumerable.Empty(), 30, 30000); + assessmentSectionStub.Expect(asm => asm.FailureMechanismContribution).Return(failureMechanismContribution); + mockRepository.ReplayAll(); - var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + ImportHydraulicBoundaryDatabase(assessmentSectionStub); + var hydraulicBoundaryLocation = assessmentSectionStub.HydraulicBoundaryDatabase.Locations.First(loc => loc.Id == 1300001); + + var activity = new DesignWaterLevelCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); + // Call Action call = () => activity.Run(); @@ -151,6 +162,7 @@ StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculationName), msgs[4]); }); Assert.AreEqual(ActivityState.Executed, activity.State); + mockRepository.VerifyAll(); } [Test] @@ -187,16 +199,23 @@ public void Run_CalculationAlreadyRan_ValidationAndCalculationNotPerformedAndStateSkipped() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); + var mockRepository = new MockRepository(); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.Expect(o => o.NotifyObservers()); + var failureMechanismContribution = new FailureMechanismContribution(Enumerable.Empty(), 30, 30000); + assessmentSectionStub.Expect(asm => asm.FailureMechanismContribution).Return(failureMechanismContribution); + mockRepository.ReplayAll(); + + ImportHydraulicBoundaryDatabase(assessmentSectionStub); + var designWaterLevel = 3.0; var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1) { DesignWaterLevel = designWaterLevel }; - var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + var activity = new DesignWaterLevelCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); // Call Action call = () => activity.Run(); @@ -214,18 +233,23 @@ public void Finish_ValidCalculationAndRun_SetsDesignWaterLevelAndNotifyObservers() { // Setup - var mocks = new MockRepository(); - var observerMock = mocks.StrictMock(); + var mockRepository = new MockRepository(); + var observerMock = mockRepository.StrictMock(); observerMock.Expect(o => o.UpdateObserver()); - mocks.ReplayAll(); - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.Expect(o => o.NotifyObservers()); - var hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(loc => loc.Id == 1300001); + var failureMechanismContribution = new FailureMechanismContribution(Enumerable.Empty(), 30, 30000); + assessmentSectionStub.Expect(asm => asm.FailureMechanismContribution).Return(failureMechanismContribution); + mockRepository.ReplayAll(); + + ImportHydraulicBoundaryDatabase(assessmentSectionStub); + + var hydraulicBoundaryLocation = assessmentSectionStub.HydraulicBoundaryDatabase.Locations.First(loc => loc.Id == 1300001); hydraulicBoundaryLocation.Attach(observerMock); - var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + var activity = new DesignWaterLevelCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); activity.Run(); @@ -234,25 +258,30 @@ // Assert Assert.IsFalse(double.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel)); - mocks.VerifyAll(); + mockRepository.VerifyAll(); } [Test] public void Finish_InvalidCalculationAndRun_DoesNotSetDesignWaterlevelAndUpdateObserver() { // Setup - var mocks = new MockRepository(); - var observerMock = mocks.StrictMock(); + var mockRepository = new MockRepository(); + var observerMock = mockRepository.StrictMock(); observerMock.Expect(o => o.UpdateObserver()); - mocks.ReplayAll(); - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.Expect(o => o.NotifyObservers()); + var failureMechanismContribution = new FailureMechanismContribution(Enumerable.Empty(), 30, 30000); + assessmentSectionStub.Expect(asm => asm.FailureMechanismContribution).Return(failureMechanismContribution); + mockRepository.ReplayAll(); + + ImportHydraulicBoundaryDatabase(assessmentSectionStub); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1); hydraulicBoundaryLocation.Attach(observerMock); - var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + var activity = new DesignWaterLevelCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); activity.Run(); @@ -261,23 +290,27 @@ // Assert Assert.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel); - mocks.VerifyAll(); + mockRepository.VerifyAll(); } [Test] public void Finish_CalculationAlreadyRan_FinishNotPerformed() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); + var mockRepository = new MockRepository(); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.Expect(o => o.NotifyObservers()); + mockRepository.ReplayAll(); - var designWaterLevel = 3.0; + ImportHydraulicBoundaryDatabase(assessmentSectionStub); + + const double designWaterLevel = 3.0; var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1) { DesignWaterLevel = designWaterLevel }; - var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + var activity = new DesignWaterLevelCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); activity.Run(); @@ -286,16 +319,15 @@ // Assert Assert.AreEqual(designWaterLevel, hydraulicBoundaryLocation.DesignWaterLevel); + mockRepository.VerifyAll(); } - private void ImportHydraulicBoundaryDatabase(AssessmentSection assessmentSection) + private void ImportHydraulicBoundaryDatabase(IAssessmentSection assessmentSection) { string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); using (var importer = new HydraulicBoundaryDatabaseImporter()) - { importer.Import(assessmentSection, validFilePath); - } } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/WaveHeightCalculationActivityTest.cs =================================================================== diff -u -ra2f070e495d1ac6307fe0267d58aade65f35a5d8 -r6fc38f8582161da49669e8785efa98ad32cc02ae --- Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/WaveHeightCalculationActivityTest.cs (.../WaveHeightCalculationActivityTest.cs) (revision a2f070e495d1ac6307fe0267d58aade65f35a5d8) +++ Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/WaveHeightCalculationActivityTest.cs (.../WaveHeightCalculationActivityTest.cs) (revision 6fc38f8582161da49669e8785efa98ad32cc02ae) @@ -28,8 +28,9 @@ using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Contribution; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.HydraRing.Data; -using Ringtoets.Integration.Data; using Ringtoets.Integration.Plugin.FileImporters; namespace Ringtoets.Integration.Service.Test @@ -43,9 +44,9 @@ public void ParameteredConstructor_ExpectedValues() { // Setup - var mocks = new MockRepository(); - var assessmentSectionMock = mocks.StrictMock(); - mocks.ReplayAll(); + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.StrictMock(); + mockRepository.ReplayAll(); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 0, 0); @@ -60,11 +61,11 @@ Assert.IsNull(activity.ProgressText); Assert.AreEqual(ActivityState.None, activity.State); - mocks.VerifyAll(); + mockRepository.VerifyAll(); } [Test] - public void ParameteredConstructor_AssessmentSectionNull_ThrowsArgumentNullException() + public void ParameteredConstructor_IAssessmentSectionNull_ThrowsArgumentNullException() { // Setup var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 0, 0); @@ -81,32 +82,33 @@ public void ParameteredConstructor_HydraulicBoundaryLocationNull_ThrowsArgumentNullException() { // Setup - var mocks = new MockRepository(); - var assessmentSectionMock = mocks.StrictMock(); - mocks.ReplayAll(); + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.StrictMock(); + mockRepository.ReplayAll(); // Call TestDelegate call = () => new WaveHeightCalculationActivity(assessmentSectionMock, null); // Assert var exception = Assert.Throws(call); Assert.AreEqual("hydraulicBoundaryLocation", exception.ParamName); + mockRepository.VerifyAll(); } [Test] public void Run_InvalidHydraulicBoundaryDatabase_PerformValidationAndLogStartAndEndAndError() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + var mockRepository = new MockRepository(); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { - HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - FilePath = Path.Combine(testDataPath, "notexisting.sqlite") - } + FilePath = Path.Combine(testDataPath, "notexisting.sqlite") }; + mockRepository.ReplayAll(); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 0, 0); - var activity = new WaveHeightCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + var activity = new WaveHeightCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); // Call Action call = () => activity.Run(); @@ -122,19 +124,26 @@ StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculationName), msgs[2]); }); Assert.AreEqual(ActivityState.Failed, activity.State); + mockRepository.VerifyAll(); } [Test] public void Run_ValidHydraulicBoundaryDatabaseAndHydraulicBoundaryLocation_PerformValidationAndCalculationAndLogStartAndEnd() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); + var mockRepository = new MockRepository(); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.Expect(o => o.NotifyObservers()); - var hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(loc => loc.Id == 1300001); + var failureMechanismContribution = new FailureMechanismContribution(Enumerable.Empty(), 30, 30000); + assessmentSectionStub.Expect(asm => asm.FailureMechanismContribution).Return(failureMechanismContribution); + mockRepository.ReplayAll(); - var activity = new WaveHeightCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + ImportHydraulicBoundaryDatabase(assessmentSectionStub); + var hydraulicBoundaryLocation = assessmentSectionStub.HydraulicBoundaryDatabase.Locations.First(loc => loc.Id == 1300001); + var activity = new WaveHeightCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); + // Call Action call = () => activity.Run(); @@ -150,19 +159,26 @@ StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ",calculationName), msgs[4]); }); Assert.AreEqual(ActivityState.Executed, activity.State); + mockRepository.VerifyAll(); } [Test] public void Run_ValidHydraulicBoundaryDatabaseInvalidHydraulicBoundaryLocation_PerformValidationAndCalculationAndLogStartAndEndAndError() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); + var mockRepository = new MockRepository(); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.Expect(o => o.NotifyObservers()); - var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1); + var failureMechanismContribution = new FailureMechanismContribution(Enumerable.Empty(), 30, 30000); + assessmentSectionStub.Expect(asm => asm.FailureMechanismContribution).Return(failureMechanismContribution); + mockRepository.ReplayAll(); - var activity = new WaveHeightCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + ImportHydraulicBoundaryDatabase(assessmentSectionStub); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1); + var activity = new WaveHeightCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); + // Call Action call = () => activity.Run(); @@ -180,22 +196,27 @@ }); Assert.AreEqual(ActivityState.Failed, activity.State); Assert.IsNaN(hydraulicBoundaryLocation.WaveHeight); + mockRepository.VerifyAll(); } [Test] public void Run_CalculationAlreadyRan_ValidationAndCalculationNotPerformedAndStateSkipped() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); + var mockRepository = new MockRepository(); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.Expect(o => o.NotifyObservers()); + mockRepository.ReplayAll(); + ImportHydraulicBoundaryDatabase(assessmentSectionStub); + const double waveHeight = 3.0; var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1) { WaveHeight = waveHeight }; - var activity = new WaveHeightCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + var activity = new WaveHeightCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); // Call Action call = () => activity.Run(); @@ -207,24 +228,30 @@ Assert.AreEqual(0, msgs.Length); }); Assert.AreEqual(ActivityState.Skipped, activity.State); + mockRepository.VerifyAll(); } [Test] public void Finish_ValidCalculationAndRun_SetsWaveHeightAndNotifyObservers() { // Setup - var mocks = new MockRepository(); - var observerMock = mocks.StrictMock(); + var mockRepository = new MockRepository(); + var observerMock = mockRepository.StrictMock(); observerMock.Expect(o => o.UpdateObserver()); - mocks.ReplayAll(); - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.Expect(o => o.NotifyObservers()); - var hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(loc => loc.Id == 1300001); + var failureMechanismContribution = new FailureMechanismContribution(Enumerable.Empty(), 30, 30000); + assessmentSectionStub.Expect(asm => asm.FailureMechanismContribution).Return(failureMechanismContribution); + mockRepository.ReplayAll(); + + ImportHydraulicBoundaryDatabase(assessmentSectionStub); + + var hydraulicBoundaryLocation = assessmentSectionStub.HydraulicBoundaryDatabase.Locations.First(loc => loc.Id == 1300001); hydraulicBoundaryLocation.Attach(observerMock); - var activity = new WaveHeightCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + var activity = new WaveHeightCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); activity.Run(); @@ -233,25 +260,30 @@ // Assert Assert.IsFalse(double.IsNaN(hydraulicBoundaryLocation.WaveHeight)); - mocks.VerifyAll(); + mockRepository.VerifyAll(); } [Test] public void Finish_InvalidCalculationAndRun_DoesNotSetWaveHeightAndUpdateObserver() { // Setup - var mocks = new MockRepository(); - var observerMock = mocks.StrictMock(); + var mockRepository = new MockRepository(); + var observerMock = mockRepository.StrictMock(); observerMock.Expect(o => o.UpdateObserver()); - mocks.ReplayAll(); - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.Expect(o => o.NotifyObservers()); + var failureMechanismContribution = new FailureMechanismContribution(Enumerable.Empty(), 30, 30000); + assessmentSectionStub.Expect(asm => asm.FailureMechanismContribution).Return(failureMechanismContribution); + mockRepository.ReplayAll(); + + ImportHydraulicBoundaryDatabase(assessmentSectionStub); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1); hydraulicBoundaryLocation.Attach(observerMock); - var activity = new WaveHeightCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + var activity = new WaveHeightCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); activity.Run(); @@ -260,23 +292,27 @@ // Assert Assert.IsNaN(hydraulicBoundaryLocation.WaveHeight); - mocks.VerifyAll(); + mockRepository.VerifyAll(); } [Test] public void Finish_CalculationAlreadyRan_FinishNotPerformed() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); + var mockRepository = new MockRepository(); + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.Expect(o => o.NotifyObservers()); + mockRepository.ReplayAll(); + ImportHydraulicBoundaryDatabase(assessmentSectionStub); + const double waveHeight = 3.0; var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1) { WaveHeight = waveHeight }; - var activity = new WaveHeightCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + var activity = new WaveHeightCalculationActivity(assessmentSectionStub, hydraulicBoundaryLocation); activity.Run(); @@ -285,10 +321,10 @@ // Assert Assert.AreEqual(waveHeight, hydraulicBoundaryLocation.WaveHeight); + mockRepository.VerifyAll(); } - - private void ImportHydraulicBoundaryDatabase(AssessmentSection assessmentSection) + private void ImportHydraulicBoundaryDatabase(IAssessmentSection assessmentSection) { string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite");