Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Service.Test/StabilityStoneCoverWaveConditionsCalculationServiceTest.cs =================================================================== diff -u -ra91af2b4cf186d4c53e839f6ce44b2ffc2895831 -rd5fa3b4ec163a5e7533295453488035b21045de7 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Service.Test/StabilityStoneCoverWaveConditionsCalculationServiceTest.cs (.../StabilityStoneCoverWaveConditionsCalculationServiceTest.cs) (revision a91af2b4cf186d4c53e839f6ce44b2ffc2895831) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Service.Test/StabilityStoneCoverWaveConditionsCalculationServiceTest.cs (.../StabilityStoneCoverWaveConditionsCalculationServiceTest.cs) (revision d5fa3b4ec163a5e7533295453488035b21045de7) @@ -593,14 +593,45 @@ calculator.LastErrorContent = "An error occured"; calculator.EndInFailure = true; + var exception = false; + // Call - TestDelegate call = () => new StabilityStoneCoverWaveConditionsCalculationService().Calculate(calculation, - assessmentSectionStub, - failureMechanism.GeneralInput, - validFilePath); + Action call = () => + { + try + { + new StabilityStoneCoverWaveConditionsCalculationService().Calculate(calculation, + assessmentSectionStub, + failureMechanism.GeneralInput, + validFilePath); + } + catch (HydraRingFileParserException) + { + exception = true; + } + }; // Assert - Assert.Throws(call); + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(7, msgs.Length); + + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); + Assert.AreEqual(string.Format("Berekening '{0}' voor blokken gestart.", calculation.Name), msgs[1]); + + var waterLevel = calculation.InputParameters.WaterLevels.First(); + + Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' gestart.", calculation.Name, waterLevel), msgs[2]); + StringAssert.StartsWith(string.Format("Berekening '{0}' voor waterstand '{1}' is niet gelukt. Bekijk het foutrapport door op details te klikken.", + calculation.Name, waterLevel), msgs[3]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie:", msgs[4]); + Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd.", calculation.Name, waterLevel), msgs[5]); + + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[6]); + }); + Assert.IsTrue(exception); + mockRepository.VerifyAll(); } } @@ -625,14 +656,45 @@ var calculator = ((TestHydraRingCalculatorFactory) HydraRingCalculatorFactory.Instance).WaveConditionsCosineCalculator; calculator.EndInFailure = true; + var exception = false; + // Call - TestDelegate call = () => new StabilityStoneCoverWaveConditionsCalculationService().Calculate(calculation, - assessmentSectionStub, - failureMechanism.GeneralInput, - validFilePath); + Action call = () => + { + try + { + new StabilityStoneCoverWaveConditionsCalculationService().Calculate(calculation, + assessmentSectionStub, + failureMechanism.GeneralInput, + validFilePath); + } + catch (HydraRingFileParserException) + { + exception = true; + } + }; // Assert - Assert.Throws(call); + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(7, msgs.Length); + + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); + Assert.AreEqual(string.Format("Berekening '{0}' voor blokken gestart.", calculation.Name), msgs[1]); + + var waterLevel = calculation.InputParameters.WaterLevels.First(); + + Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' gestart.", calculation.Name, waterLevel), msgs[2]); + StringAssert.StartsWith(string.Format("Berekening '{0}' voor waterstand '{1}' is niet gelukt. Er is geen foutrapport beschikbaar.", + calculation.Name, waterLevel), msgs[3]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie:", msgs[4]); + Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd.", calculation.Name, waterLevel), msgs[5]); + + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[6]); + }); + Assert.IsTrue(exception); + mockRepository.VerifyAll(); } } @@ -658,15 +720,48 @@ calculator.EndInFailure = false; calculator.LastErrorContent = "An error occured"; + var exception = false; + var exceptionMessage = string.Empty; + // Call - TestDelegate call = () => new StabilityStoneCoverWaveConditionsCalculationService().Calculate(calculation, - assessmentSectionStub, - failureMechanism.GeneralInput, - validFilePath); + Action call = () => + { + try + { + new StabilityStoneCoverWaveConditionsCalculationService().Calculate(calculation, + assessmentSectionStub, + failureMechanism.GeneralInput, + validFilePath); + } + catch (HydraRingFileParserException e) + { + exception = true; + exceptionMessage = e.Message; + } + }; // Assert - var exception = Assert.Throws(call); - Assert.AreEqual(calculator.LastErrorContent, exception.Message); + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(7, msgs.Length); + + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); + Assert.AreEqual(string.Format("Berekening '{0}' voor blokken gestart.", calculation.Name), msgs[1]); + + var waterLevel = calculation.InputParameters.WaterLevels.First(); + + Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' gestart.", calculation.Name, waterLevel), msgs[2]); + StringAssert.StartsWith(string.Format("Berekening '{0}' voor waterstand '{1}' is niet gelukt. Bekijk het foutrapport door op details te klikken.", + calculation.Name, waterLevel), msgs[3]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie:", msgs[4]); + Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd.", calculation.Name, waterLevel), msgs[5]); + + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[6]); + }); + Assert.IsTrue(exception); + Assert.AreEqual(calculator.LastErrorContent, exceptionMessage); + mockRepository.VerifyAll(); } }