Index: Core/Common/test/Core.Common.TestUtil/TestHelper.cs =================================================================== diff -u -ra979e6ebe32c21456dd9139b3fb07f4a499351c1 -r797860a90e2e806327a86f77e20a368eaf25d6ed --- Core/Common/test/Core.Common.TestUtil/TestHelper.cs (.../TestHelper.cs) (revision a979e6ebe32c21456dd9139b3fb07f4a499351c1) +++ Core/Common/test/Core.Common.TestUtil/TestHelper.cs (.../TestHelper.cs) (revision 797860a90e2e806327a86f77e20a368eaf25d6ed) @@ -228,6 +228,19 @@ } /// + /// Method use to perform any type of assertion on the generated log while performing + /// a particular action. + /// + /// Action to be performed while recording the log. + /// The assertion logic performed on the generated log-messages. + public static void AssertLogMessagesAndLoggedExceptions(Action action, + Action>> assertLogMessagesAndExceptions) + { + IEnumerable> renderedMessages = GetAllRenderedMessagesWithExceptions(action); + assertLogMessagesAndExceptions(renderedMessages); + } + + /// /// Checks the number of messages in the log. /// /// Action to be performed while recording the log @@ -589,6 +602,26 @@ return renderedMessages; } + private static IEnumerable> GetAllRenderedMessagesWithExceptions(Action action) + { + var memoryAppender = new MemoryAppender(); + BasicConfigurator.Configure(memoryAppender); + LogHelper.SetLoggingLevel(Level.All); + + action(); + + List> renderedMessages = memoryAppender.GetEvents() + .Select(le => Tuple.Create(le.RenderedMessage, + le.Level, + le.ExceptionObject)) + .ToList(); + + memoryAppender.Close(); + LogHelper.ResetLogging(); + + return renderedMessages; + } + private static Color[] GetImageAsColorArray(Image image) { // Convert image to ARGB bitmap using 8bits/channel: Index: Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs =================================================================== diff -u -r2e5f2b59e81cda48f3d7ee03afa4db88abc7b1a8 -r797860a90e2e806327a86f77e20a368eaf25d6ed --- Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs (.../DesignWaterLevelCalculationService.cs) (revision 2e5f2b59e81cda48f3d7ee03afa4db88abc7b1a8) +++ Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs (.../DesignWaterLevelCalculationService.cs) (revision 797860a90e2e806327a86f77e20a368eaf25d6ed) @@ -26,6 +26,7 @@ using Core.Common.Base.IO; using Core.Common.Utils; using log4net; +using Ringtoets.Common.Data.Exceptions; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.IO.HydraRing; @@ -210,9 +211,16 @@ { if (hydraRingGeneralResult != null) { - GeneralResult generalResult = - GeneralResultConverter.CreateGeneralResultTopLevelSubMechanismIllustrationPoint(hydraRingGeneralResult); - hydraulicBoundaryLocationOutput.SetIllustrationPoints(generalResult); + try + { + GeneralResult generalResult = + GeneralResultConverter.CreateGeneralResultTopLevelSubMechanismIllustrationPoint(hydraRingGeneralResult); + hydraulicBoundaryLocationOutput.SetIllustrationPoints(generalResult); + } + catch (IllustrationPointConversionException e) + { + log.Warn("Het uitlezen van illustratiepunten is mislukt.", e); + } } } Index: Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs =================================================================== diff -u -r2e5f2b59e81cda48f3d7ee03afa4db88abc7b1a8 -r797860a90e2e806327a86f77e20a368eaf25d6ed --- Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs (.../WaveHeightCalculationService.cs) (revision 2e5f2b59e81cda48f3d7ee03afa4db88abc7b1a8) +++ Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs (.../WaveHeightCalculationService.cs) (revision 797860a90e2e806327a86f77e20a368eaf25d6ed) @@ -26,6 +26,7 @@ using Core.Common.Base.IO; using Core.Common.Utils; using log4net; +using Ringtoets.Common.Data.Exceptions; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.IO.HydraRing; @@ -211,9 +212,16 @@ { if (hydraRingGeneralResult != null) { - GeneralResult generalResult = - GeneralResultConverter.CreateGeneralResultTopLevelSubMechanismIllustrationPoint(hydraRingGeneralResult); - hydraulicBoundaryLocationOutput.SetIllustrationPoints(generalResult); + try + { + GeneralResult generalResult = + GeneralResultConverter.CreateGeneralResultTopLevelSubMechanismIllustrationPoint(hydraRingGeneralResult); + hydraulicBoundaryLocationOutput.SetIllustrationPoints(generalResult); + } + catch (IllustrationPointConversionException e) + { + log.Warn("Het uitlezen van illustratiepunten is mislukt.", e); + } } } Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs =================================================================== diff -u -r93044b3ed52a925c5321b68ff2beb886c6bf7068 -r797860a90e2e806327a86f77e20a368eaf25d6ed --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision 93044b3ed52a925c5321b68ff2beb886c6bf7068) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision 797860a90e2e806327a86f77e20a368eaf25d6ed) @@ -23,8 +23,10 @@ using System.IO; using System.Linq; using Core.Common.TestUtil; +using log4net.Core; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.Data.Exceptions; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Service.MessageProviders; using Ringtoets.Common.Service.TestUtil; @@ -128,7 +130,7 @@ [Test] [TestCase(true)] [TestCase(false)] - public void Calculate_ValidDesignWaterLevelCalculation_StartsCalculationWithRightParameters(bool readIllustrationPoints) + public void Calculate_ValidDesignWaterLevelCalculationAndConverges_StartsCalculationWithRightParametersAndLogs(bool readIllustrationPoints) { // Setup string validFilePath = Path.Combine(testDataPath, validFile); @@ -139,7 +141,8 @@ var calculator = new TestDesignWaterLevelCalculator { - IllustrationPointsResult = new TestGeneralResult() + IllustrationPointsResult = new TestGeneralResult(), + Converged = true }; var mockRepository = new MockRepository(); @@ -151,19 +154,28 @@ calculation.Expect(c => c.Id).Return(id); calculation.Expect(c => c.CalculateIllustrationPoints).Return(readIllustrationPoints); - var calculationMessageProvider = mockRepository.Stub(); - calculationMessageProvider.Stub(calc => calc.GetCalculatedNotConvergedMessage(locationName)).Return(string.Empty); + var calculationMessageProvider = mockRepository.StrictMock(); mockRepository.ReplayAll(); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call - new DesignWaterLevelCalculationService().Calculate(calculation, - validFilePath, - norm, - calculationMessageProvider); + Action call = () => new DesignWaterLevelCalculationService().Calculate(calculation, + validFilePath, + norm, + calculationMessageProvider); // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + Assert.AreEqual($"Toetspeil berekening is uitgevoerd op de tijdelijke locatie '{calculator.OutputDirectory}'. " + + "Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden.", msgs[1]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[2]); + }); + AssessmentLevelCalculationInput expectedInput = CreateInput(id, norm); AssertInput(expectedInput, calculator.ReceivedInputs.Single()); Assert.IsFalse(calculator.IsCanceled); @@ -174,6 +186,129 @@ } [Test] + [TestCase(true)] + [TestCase(false)] + public void Calculate_ValidDesignWaterLevelCalculationAndDoesNotConverge_StartsCalculationWithRightParametersAndLogsWarning(bool readIllustrationPoints) + { + // Setup + string validFilePath = Path.Combine(testDataPath, validFile); + + const long id = 100; + const string locationName = "punt_flw_ 1"; + const double norm = 1.0 / 30; + + var calculator = new TestDesignWaterLevelCalculator + { + IllustrationPointsResult = new TestGeneralResult(), + Converged = false + }; + + var mockRepository = new MockRepository(); + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath)).Return(calculator); + + var calculation = mockRepository.Stub(); + calculation.Stub(c => c.Name).Return(locationName); + calculation.Expect(c => c.Id).Return(id); + calculation.Expect(c => c.CalculateIllustrationPoints).Return(readIllustrationPoints); + + const string failedConvergenceMessage = "Did not converge"; + var calculationMessageProvider = mockRepository.StrictMock(); + calculationMessageProvider.Expect(c => c.GetCalculatedNotConvergedMessage(locationName)).Return(failedConvergenceMessage); + mockRepository.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + Action call = () => new DesignWaterLevelCalculationService().Calculate(calculation, + validFilePath, + norm, + calculationMessageProvider); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(4, msgs.Length); + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + Assert.AreEqual(failedConvergenceMessage, msgs[1]); + Assert.AreEqual($"Toetspeil berekening is uitgevoerd op de tijdelijke locatie '{calculator.OutputDirectory}'. " + + "Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden.", msgs[2]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[3]); + }); + + AssessmentLevelCalculationInput expectedInput = CreateInput(id, norm); + AssertInput(expectedInput, calculator.ReceivedInputs.Single()); + Assert.IsFalse(calculator.IsCanceled); + Assert.IsNotNull(calculation.Output); + Assert.AreEqual(readIllustrationPoints, calculation.Output.HasIllustrationPoints); + } + mockRepository.VerifyAll(); + } + + [Test] + public void Calculate_ValidDesignWaterLevelCalculationButInvalidIllustrationPointResults_StartsCalculationWithRightParametersAndLogsWarning() + { + // Setup + string validFilePath = Path.Combine(testDataPath, validFile); + + const long id = 100; + const string locationName = "punt_flw_ 1"; + const double norm = 1.0 / 30; + + var calculator = new TestDesignWaterLevelCalculator + { + IllustrationPointsResult = TestGeneralResult.CreateGeneralResultWithFaultTreeIllustrationPoints(), + Converged = true + }; + + var mockRepository = new MockRepository(); + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath)).Return(calculator); + + var calculation = mockRepository.Stub(); + calculation.Stub(c => c.Name).Return(locationName); + calculation.Expect(c => c.Id).Return(id); + calculation.Expect(c => c.CalculateIllustrationPoints).Return(true); + + var calculationMessageProvider = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + Action call = () => new DesignWaterLevelCalculationService().Calculate(calculation, + validFilePath, + norm, + calculationMessageProvider); + + // Assert + TestHelper.AssertLogMessagesAndLoggedExceptions(call, messages => + { + Tuple[] tupleArray = messages.ToArray(); + + string[] msgs = tupleArray.Select(tuple => tuple.Item1).ToArray(); + Assert.AreEqual(4, msgs.Length); + + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + Assert.AreEqual("Het uitlezen van illustratiepunten is mislukt.", msgs[1]); + Assert.AreEqual($"Toetspeil berekening is uitgevoerd op de tijdelijke locatie '{calculator.OutputDirectory}'. " + + "Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden.", msgs[2]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[3]); + + Assert.IsInstanceOf(tupleArray[1].Item3); + }); + + AssessmentLevelCalculationInput expectedInput = CreateInput(id, norm); + AssertInput(expectedInput, calculator.ReceivedInputs.Single()); + Assert.IsFalse(calculator.IsCanceled); + Assert.IsNotNull(calculation.Output); + Assert.IsFalse(calculation.Output.HasIllustrationPoints); + } + mockRepository.VerifyAll(); + } + + [Test] public void Calculate_ValidDesignWaterLevelCalculationThrowsException_ThrowsHydraRingFileParserException() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj =================================================================== diff -u -ra1d26cb03e95b46fe8600b53a8e91dfde417ca56 -r797860a90e2e806327a86f77e20a368eaf25d6ed --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj (.../Ringtoets.Common.Service.Test.csproj) (revision a1d26cb03e95b46fe8600b53a8e91dfde417ca56) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj (.../Ringtoets.Common.Service.Test.csproj) (revision 797860a90e2e806327a86f77e20a368eaf25d6ed) @@ -39,6 +39,10 @@ MinimumRecommendedRules.ruleset + + ..\..\..\..\packages\log4net.2.0.4\lib\net40-full\log4net.dll + True + ..\..\..\..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll True @@ -96,6 +100,7 @@ Copying.licenseheader + Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs =================================================================== diff -u -r0913b25b262329fc46c40cc84e4c127dae21b85f -r797860a90e2e806327a86f77e20a368eaf25d6ed --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs (.../WaveHeightCalculationServiceTest.cs) (revision 0913b25b262329fc46c40cc84e4c127dae21b85f) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs (.../WaveHeightCalculationServiceTest.cs) (revision 797860a90e2e806327a86f77e20a368eaf25d6ed) @@ -23,8 +23,10 @@ using System.IO; using System.Linq; using Core.Common.TestUtil; +using log4net.Core; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.Data.Exceptions; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Service.MessageProviders; using Ringtoets.Common.Service.TestUtil; @@ -128,7 +130,7 @@ [Test] [TestCase(true)] [TestCase(false)] - public void Calculate_ValidWaveHeightCalculation_StartsCalculationWithRightParameters(bool readIllustrationPoints) + public void Calculate_ValidWaveHeightCalculationAndConverges_StartsCalculationWithRightParametersAndLogs(bool readIllustrationPoints) { // Setup string validFilePath = Path.Combine(testDataPath, validFile); @@ -139,7 +141,8 @@ var calculator = new TestWaveHeightCalculator { - IllustrationPointsResult = new TestGeneralResult() + IllustrationPointsResult = new TestGeneralResult(), + Converged = true }; var mockRepository = new MockRepository(); @@ -151,28 +154,159 @@ calculation.Expect(c => c.Id).Return(id); calculation.Expect(c => c.CalculateIllustrationPoints).Return(readIllustrationPoints); - var calculationMessageProvider = mockRepository.Stub(); - calculationMessageProvider.Stub(calc => calc.GetCalculatedNotConvergedMessage(locationName)).Return(string.Empty); + var calculationMessageProvider = mockRepository.StrictMock(); mockRepository.ReplayAll(); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { - new WaveHeightCalculationService().Calculate(calculation, - validFilePath, - norm, - calculationMessageProvider); + Action call = () => new WaveHeightCalculationService().Calculate(calculation, + validFilePath, + norm, + calculationMessageProvider); // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + Assert.AreEqual($"Golfhoogte berekening is uitgevoerd op de tijdelijke locatie '{calculator.OutputDirectory}'. " + + "Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden.", msgs[1]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[2]); + }); + AssessmentLevelCalculationInput expectedInput = CreateInput(id, norm); AssertInput(expectedInput, calculator.ReceivedInputs.Single()); Assert.IsFalse(calculator.IsCanceled); + Assert.IsNotNull(calculation.Output); + Assert.AreEqual(readIllustrationPoints, calculation.Output.HasIllustrationPoints); + } + mockRepository.VerifyAll(); + } + [Test] + [TestCase(true)] + [TestCase(false)] + public void Calculate_ValidWaveHeightCalculationAndDoesNotConverge_StartsCalculationWithRightParametersAndLogsWarning(bool readIllustrationPoints) + { + // Setup + string validFilePath = Path.Combine(testDataPath, validFile); + + const long id = 100; + const string locationName = "punt_flw_ 1"; + const double norm = 1.0 / 30; + + var calculator = new TestWaveHeightCalculator + { + IllustrationPointsResult = new TestGeneralResult(), + Converged = false + }; + + var mockRepository = new MockRepository(); + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath)).Return(calculator); + + var calculation = mockRepository.Stub(); + calculation.Stub(c => c.Name).Return(locationName); + calculation.Expect(c => c.Id).Return(id); + calculation.Expect(c => c.CalculateIllustrationPoints).Return(readIllustrationPoints); + + var calculationMessageProvider = mockRepository.StrictMock(); + const string failedConvergenceMessage = "Did not converge"; + calculationMessageProvider.Expect(calc => calc.GetCalculatedNotConvergedMessage(locationName)).Return(failedConvergenceMessage); + mockRepository.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + Action call = () => new WaveHeightCalculationService().Calculate(calculation, + validFilePath, + norm, + calculationMessageProvider); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(4, msgs.Length); + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + Assert.AreEqual(failedConvergenceMessage, msgs[1]); + Assert.AreEqual($"Golfhoogte berekening is uitgevoerd op de tijdelijke locatie '{calculator.OutputDirectory}'. " + + "Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden.", msgs[2]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[3]); + }); + + AssessmentLevelCalculationInput expectedInput = CreateInput(id, norm); + AssertInput(expectedInput, calculator.ReceivedInputs.Single()); + Assert.IsFalse(calculator.IsCanceled); + Assert.IsNotNull(calculation.Output); Assert.AreEqual(readIllustrationPoints, calculation.Output.HasIllustrationPoints); } mockRepository.VerifyAll(); } [Test] + public void Calculate_ValidDesignWaterLevelCalculationButInvalidIllustrationPointResults_StartsCalculationWithRightParametersAndLogsWarning() + { + // Setup + string validFilePath = Path.Combine(testDataPath, validFile); + + const long id = 100; + const string locationName = "punt_flw_ 1"; + const double norm = 1.0 / 30; + + var calculator = new TestWaveHeightCalculator + { + IllustrationPointsResult = TestGeneralResult.CreateGeneralResultWithFaultTreeIllustrationPoints(), + Converged = true + }; + + var mockRepository = new MockRepository(); + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath)).Return(calculator); + + var calculation = mockRepository.Stub(); + calculation.Stub(c => c.Name).Return(locationName); + calculation.Expect(c => c.Id).Return(id); + calculation.Expect(c => c.CalculateIllustrationPoints).Return(true); + + var calculationMessageProvider = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + Action call = () => new WaveHeightCalculationService().Calculate(calculation, + validFilePath, + norm, + calculationMessageProvider); + + // Assert + TestHelper.AssertLogMessagesAndLoggedExceptions(call, messages => + { + Tuple[] tupleArray = messages.ToArray(); + + string[] msgs = tupleArray.Select(tuple => tuple.Item1).ToArray(); + Assert.AreEqual(4, msgs.Length); + + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + Assert.AreEqual("Het uitlezen van illustratiepunten is mislukt.", msgs[1]); + Assert.AreEqual($"Golfhoogte berekening is uitgevoerd op de tijdelijke locatie '{calculator.OutputDirectory}'. " + + "Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden.", msgs[2]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[3]); + + Assert.IsInstanceOf(tupleArray[1].Item3); + }); + + AssessmentLevelCalculationInput expectedInput = CreateInput(id, norm); + AssertInput(expectedInput, calculator.ReceivedInputs.Single()); + Assert.IsFalse(calculator.IsCanceled); + Assert.IsNotNull(calculation.Output); + Assert.IsFalse(calculation.Output.HasIllustrationPoints); + } + mockRepository.VerifyAll(); + } + + [Test] public void Calculate_ValidWaveHeightCalculationThrowsException_ThrowsHydraRingFileParserException() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/app.config =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/app.config (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/app.config (revision 797860a90e2e806327a86f77e20a368eaf25d6ed) @@ -0,0 +1,33 @@ + + + + + + + + + + + + \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/packages.config =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -r797860a90e2e806327a86f77e20a368eaf25d6ed --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/packages.config (.../packages.config) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/packages.config (.../packages.config) (revision 797860a90e2e806327a86f77e20a368eaf25d6ed) @@ -1,4 +1,5 @@ - + Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil.Test/IllustrationPoints/TestGeneralResultTest.cs =================================================================== diff -u -r66a40e718fdf95596f8897d81af4a1a0144cfae4 -r797860a90e2e806327a86f77e20a368eaf25d6ed --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil.Test/IllustrationPoints/TestGeneralResultTest.cs (.../TestGeneralResultTest.cs) (revision 66a40e718fdf95596f8897d81af4a1a0144cfae4) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil.Test/IllustrationPoints/TestGeneralResultTest.cs (.../TestGeneralResultTest.cs) (revision 797860a90e2e806327a86f77e20a368eaf25d6ed) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; +using System.Linq; using NUnit.Framework; using Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints; using Ringtoets.HydraRing.Calculation.TestUtil.IllustrationPoints; @@ -40,17 +42,34 @@ var expectedWindDirection = new TestWindDirection(); AssertWindDirection(expectedWindDirection, generalResult.GoverningWindDirection); - Assert.IsEmpty(generalResult.Stochasts); - Assert.IsEmpty(generalResult.IllustrationPoints); + CollectionAssert.IsEmpty(generalResult.Stochasts); + CollectionAssert.IsEmpty(generalResult.IllustrationPoints); } + [Test] + public void CreateGeneralResultWithFaultTreeIllustrationPoints_ExpectedProperties() + { + // Call + TestGeneralResult generalResult = TestGeneralResult.CreateGeneralResultWithFaultTreeIllustrationPoints(); + + // Assert + Assert.IsInstanceOf(generalResult); + Assert.AreEqual(0, generalResult.Beta); + + var expectedWindDirection = new TestWindDirection(); + AssertWindDirection(expectedWindDirection, generalResult.GoverningWindDirection); + CollectionAssert.IsEmpty(generalResult.Stochasts); + + KeyValuePair topLevelIllustrationPoint = + generalResult.IllustrationPoints.Single(); + WindDirectionClosingSituation actualWindDirectionClosingSituation = topLevelIllustrationPoint.Key; + AssertWindDirection(expectedWindDirection, actualWindDirectionClosingSituation.WindDirection); + Assert.AreEqual("closing situation", actualWindDirectionClosingSituation.ClosingSituation); + Assert.IsInstanceOf(topLevelIllustrationPoint.Value.Data); + } + private static void AssertWindDirection(WindDirection expected, WindDirection actual) { - if (expected == null) - { - Assert.IsNull(actual); - return; - } Assert.AreEqual(expected.Name, actual.Name); Assert.AreEqual(expected.Angle, actual.Angle); } Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/IllustrationPoints/TestGeneralResult.cs =================================================================== diff -u -r66a40e718fdf95596f8897d81af4a1a0144cfae4 -r797860a90e2e806327a86f77e20a368eaf25d6ed --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/IllustrationPoints/TestGeneralResult.cs (.../TestGeneralResult.cs) (revision 66a40e718fdf95596f8897d81af4a1a0144cfae4) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/IllustrationPoints/TestGeneralResult.cs (.../TestGeneralResult.cs) (revision 797860a90e2e806327a86f77e20a368eaf25d6ed) @@ -38,5 +38,20 @@ new TestWindDirection(), Enumerable.Empty(), new Dictionary()) {} + + /// + /// Creates a new instance of with only fault tree + /// illustration points. + /// + /// A with fault tree illustration points. + public static TestGeneralResult CreateGeneralResultWithFaultTreeIllustrationPoints() + { + var generalResult = new TestGeneralResult(); + + generalResult.IllustrationPoints.Add(new WindDirectionClosingSituation(new TestWindDirection(), "closing situation"), + new IllustrationPointTreeNode(new TestFaultTreeIllustrationPoint())); + + return generalResult; + } } } \ No newline at end of file