Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationActivityTest.cs =================================================================== diff -u -r5fca1638d8f9510eebe352a8a9a86551d7ce9e61 -rce190360da30edf73fb464cc0fea1d9a795aa5d4 --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationActivityTest.cs (.../WaveHeightCalculationActivityTest.cs) (revision 5fca1638d8f9510eebe352a8a9a86551d7ce9e61) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationActivityTest.cs (.../WaveHeightCalculationActivityTest.cs) (revision ce190360da30edf73fb464cc0fea1d9a795aa5d4) @@ -52,42 +52,40 @@ // Setup const string locationName = "locationName"; const string activityName = "GetActivityName"; - - var hydraulicBoundaryLocationMock = mockRepository.Stub(); - hydraulicBoundaryLocationMock.Expect(hbl => hbl.Name).Return(locationName); - + var calculationMessageProviderMock = mockRepository.StrictMock(); calculationMessageProviderMock.Expect(calc => calc.GetActivityName(locationName)).Return(activityName); mockRepository.ReplayAll(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, locationName, 0, 0); + string validFilePath = Path.Combine(testDataPath, validFile); // Call - var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocationMock, validFilePath, "", 1, calculationMessageProviderMock); + var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocation, validFilePath, "", 1, calculationMessageProviderMock); // Assert Assert.IsInstanceOf(activity); Assert.AreSame(activityName, activity.Name); Assert.IsNull(activity.ProgressText); Assert.AreEqual(ActivityState.None, activity.State); + mockRepository.VerifyAll(); } [Test] public void ParameteredConstructor_NullCalculationServiceMessageProvider_ThrowsArgumentNullException() { // Setup - var hydraulicBoundaryLocationMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, string.Empty, 0, 0); string validFilePath = Path.Combine(testDataPath, validFile); // Call - TestDelegate call = () => new WaveHeightCalculationActivity(hydraulicBoundaryLocationMock, validFilePath, "", 1, null); + TestDelegate call = () => new WaveHeightCalculationActivity(hydraulicBoundaryLocation, validFilePath, "", 1, null); // Assert var exception = Assert.Throws(call); Assert.AreEqual("messageProvider", exception.ParamName); - mockRepository.VerifyAll(); } [Test] @@ -117,19 +115,18 @@ const string activityName = "GetActivityName"; const string calculationName = "locationName"; - var hydraulicBoundaryLocationMock = mockRepository.Stub(); - - hydraulicBoundaryLocationMock.Expect(hbl => hbl.Id).Return(1); - hydraulicBoundaryLocationMock.Expect(hbl => hbl.Name).Return(locationName).Repeat.AtLeastOnce(); - hydraulicBoundaryLocationMock.WaveHeight = new RoundedDouble(2, double.NaN); - var calculationMessageProviderMock = mockRepository.StrictMock(); calculationMessageProviderMock.Expect(calc => calc.GetActivityName(locationName)).Return(activityName); calculationMessageProviderMock.Expect(calc => calc.GetCalculationName(locationName)).Return(calculationName).Repeat.AtLeastOnce(); mockRepository.ReplayAll(); - var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocationMock, inValidFilePath, "", 1, calculationMessageProviderMock); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, locationName, 0, 0) + { + WaveHeight = new RoundedDouble(2, double.NaN) + }; + var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocation, inValidFilePath, "", 1, calculationMessageProviderMock); + // Call Action call = () => activity.Run(); @@ -156,16 +153,17 @@ const string ringId = "11-1"; const double norm = 30; - var hydraulicBoundaryLocationMock = mockRepository.Stub(); - hydraulicBoundaryLocationMock.Expect(hbl => hbl.Name).Return(locationName).Repeat.AtLeastOnce(); - hydraulicBoundaryLocationMock.WaveHeight = new RoundedDouble(2, double.NaN); - var calculationMessageProviderMock = mockRepository.StrictMock(); calculationMessageProviderMock.Expect(calc => calc.GetActivityName(locationName)).Return(activityName); calculationMessageProviderMock.Expect(calc => calc.GetCalculationName(locationName)).Return(calculationName).Repeat.AtLeastOnce(); mockRepository.ReplayAll(); - var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocationMock, + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, locationName, 0, 0) + { + WaveHeight = new RoundedDouble(2, double.NaN) + }; + + var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocation, validFilePath, ringId, norm, calculationMessageProviderMock); @@ -179,7 +177,7 @@ // Assert Assert.AreSame(calculationMessageProviderMock, testService.MessageProvider); - Assert.AreSame(hydraulicBoundaryLocationMock, testService.HydraulicBoundaryLocation); + Assert.AreSame(hydraulicBoundaryLocation, testService.HydraulicBoundaryLocation); Assert.AreEqual(validFilePath, testService.HydraulicBoundaryDatabaseFilePath); Assert.AreEqual(ringId, testService.RingId); Assert.AreEqual(norm, testService.Norm); @@ -196,16 +194,21 @@ const string locationName = "locationName"; const string activityName = "GetActivityName"; - var hydraulicBoundaryLocationMock = mockRepository.Stub(); - hydraulicBoundaryLocationMock.Expect(hbl => hbl.Name).Return(locationName).Repeat.AtLeastOnce(); - hydraulicBoundaryLocationMock.WaveHeight = new RoundedDouble(2, 3.0); - var calculationMessageProviderMock = mockRepository.StrictMock(); calculationMessageProviderMock.Expect(calc => calc.GetActivityName(locationName)).Return(activityName); mockRepository.ReplayAll(); - var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocationMock, validFilePath, "", 30, calculationMessageProviderMock); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, locationName, 0, 0) + { + WaveHeight = new RoundedDouble(2, 3.0) + }; + var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocation, + validFilePath, + string.Empty, + 30, + calculationMessageProviderMock); + // Call Action call = () => activity.Run(); @@ -224,20 +227,25 @@ { // Setup const string locationName = "locationName"; - var hydraulicBoundaryLocationMock = mockRepository.Stub(); - hydraulicBoundaryLocationMock.Expect(hbl => hbl.Name).Return(locationName).Repeat.AtLeastOnce(); - hydraulicBoundaryLocationMock.WaveHeight = new RoundedDouble(2, double.NaN); - hydraulicBoundaryLocationMock.WaveHeightCalculationConvergence = CalculationConvergence.CalculatedNotConverged; var calculationMessageProviderMock = mockRepository.StrictMock(); calculationMessageProviderMock.Expect(calc => calc.GetActivityName(locationName)).Return(""); calculationMessageProviderMock.Expect(calc => calc.GetCalculationName(locationName)).Return("").Repeat.AtLeastOnce(); mockRepository.ReplayAll(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, locationName, 0, 0) + { + WaveHeight = new RoundedDouble(2, double.NaN), + WaveHeightCalculationConvergence = CalculationConvergence.CalculatedNotConverged + }; + string validFilePath = Path.Combine(testDataPath, validFile); - var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocationMock, - validFilePath, "", 30, calculationMessageProviderMock); + var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocation, + validFilePath, + string.Empty, + 30, + calculationMessageProviderMock); using (new WaveHeightCalculationServiceConfig()) { @@ -248,8 +256,8 @@ activity.Finish(); // Assert - Assert.IsFalse(double.IsNaN(hydraulicBoundaryLocationMock.WaveHeight)); - Assert.AreEqual(CalculationConvergence.CalculatedConverged, hydraulicBoundaryLocationMock.WaveHeightCalculationConvergence); + Assert.IsFalse(double.IsNaN(hydraulicBoundaryLocation.WaveHeight)); + Assert.AreEqual(CalculationConvergence.CalculatedConverged, hydraulicBoundaryLocation.WaveHeightCalculationConvergence); mockRepository.VerifyAll(); } @@ -261,17 +269,21 @@ const string locationName = "locationName"; calculationMessageProviderMock.Expect(calc => calc.GetActivityName(locationName)).Return(""); calculationMessageProviderMock.Expect(calc => calc.GetCalculationName(locationName)).Return("").Repeat.AtLeastOnce(); - - var hydraulicBoundaryLocationMock = mockRepository.Stub(); - hydraulicBoundaryLocationMock.Expect(hbl => hbl.Name).Return(locationName).Repeat.AtLeastOnce(); - hydraulicBoundaryLocationMock.WaveHeight = new RoundedDouble(2, double.NaN); - hydraulicBoundaryLocationMock.WaveHeightCalculationConvergence = CalculationConvergence.CalculatedConverged; mockRepository.ReplayAll(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, locationName, 0, 0) + { + WaveHeight = new RoundedDouble(2, double.NaN), + WaveHeightCalculationConvergence = CalculationConvergence.CalculatedConverged + }; + string validFilePath = Path.Combine(testDataPath, validFile); - var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocationMock, - validFilePath, "", 30, calculationMessageProviderMock); + var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocation, + validFilePath, + string.Empty, + 30, + calculationMessageProviderMock); using (new WaveHeightCalculationServiceConfig()) { @@ -285,8 +297,8 @@ activity.Finish(); // Assert - Assert.IsNaN(hydraulicBoundaryLocationMock.WaveHeight); - Assert.AreEqual(CalculationConvergence.CalculatedConverged, hydraulicBoundaryLocationMock.WaveHeightCalculationConvergence); + Assert.IsNaN(hydraulicBoundaryLocation.WaveHeight); + Assert.AreEqual(CalculationConvergence.CalculatedConverged, hydraulicBoundaryLocation.WaveHeightCalculationConvergence); mockRepository.VerifyAll(); } @@ -298,22 +310,23 @@ const string activityName = "getActivityName"; const string calculationNotConvergedMessage = "GetCalculatedNotConvergedMessage"; - var hydraulicBoundaryLocationMock = mockRepository.Stub(); - hydraulicBoundaryLocationMock.Expect(hbl => hbl.Name).Return(locationName).Repeat.AtLeastOnce(); - hydraulicBoundaryLocationMock.WaveHeight = new RoundedDouble(2, double.NaN); - hydraulicBoundaryLocationMock.WaveHeightCalculationConvergence = CalculationConvergence.CalculatedConverged; - var calculationMessageProviderMock = mockRepository.StrictMock(); calculationMessageProviderMock.Expect(calc => calc.GetActivityName(locationName)).Return(activityName); calculationMessageProviderMock.Expect(calc => calc.GetCalculationName(locationName)).Return("GetCalculationName").Repeat.AtLeastOnce(); calculationMessageProviderMock.Expect(calc => calc.GetCalculatedNotConvergedMessage(locationName)).Return(calculationNotConvergedMessage); mockRepository.ReplayAll(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, locationName, 0, 0) + { + WaveHeight = new RoundedDouble(2, double.NaN), + WaveHeightCalculationConvergence = CalculationConvergence.CalculatedConverged + }; + string validFilePath = Path.Combine(testDataPath, validFile); const int norm = 300; - var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocationMock, + var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocation, validFilePath, - "", + string.Empty, norm, calculationMessageProviderMock); using (new WaveHeightCalculationServiceConfig()) @@ -334,7 +347,7 @@ StringAssert.StartsWith(calculationNotConvergedMessage, msgs[0]); StringAssert.StartsWith(string.Format("Uitvoeren van '{0}' is gelukt.", activityName), msgs[1]); }); - Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, hydraulicBoundaryLocationMock.WaveHeightCalculationConvergence); + Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, hydraulicBoundaryLocation.WaveHeightCalculationConvergence); mockRepository.VerifyAll(); } @@ -344,17 +357,23 @@ // Setup RoundedDouble waveHeight = (RoundedDouble) 3.0; const string locationName = "Name"; - var hydraulicBoundaryLocationMock = mockRepository.StrictMock(); - hydraulicBoundaryLocationMock.Expect(hbl => hbl.Name).Return(locationName).Repeat.AtLeastOnce(); - hydraulicBoundaryLocationMock.Expect(hbl => hbl.WaveHeight).Return(waveHeight).Repeat.AtLeastOnce(); var calculationMessageProviderMock = mockRepository.StrictMock(); calculationMessageProviderMock.Expect(calc => calc.GetActivityName(locationName)).Return(""); mockRepository.ReplayAll(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, locationName, 0, 0) + { + WaveHeight = waveHeight + }; + string validFilePath = Path.Combine(testDataPath, validFile); - var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocationMock, validFilePath, "", 30, calculationMessageProviderMock); + var activity = new WaveHeightCalculationActivity(hydraulicBoundaryLocation, + validFilePath, + string.Empty, + 30, + calculationMessageProviderMock); activity.Run();