public void Run_CalculationWithValidInputAndValidForeshore_LogStartAndEnd(ForeshoreCalculationType calculationType) { // Setup IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput(); WaveImpactAsphaltCoverWaveConditionsCalculation calculation = GetDefaultCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); var waveImpactAsphaltCoverFailureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>(); calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(null)) .IgnoreArguments() .Return(new TestWaveConditionsCosineCalculator()) .Repeat .Twice(); mockRepository.ReplayAll(); switch (calculationType) { case ForeshoreCalculationType.NoForeshore: calculation.InputParameters.ForeshoreProfile = null; calculation.InputParameters.UseForeshore = false; calculation.InputParameters.UseBreakWater = false; break; case ForeshoreCalculationType.ForeshoreWithoutBreakWater: calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); calculation.InputParameters.UseBreakWater = false; break; case ForeshoreCalculationType.ForeshoreWithValidBreakWater: break; } using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call void Call() => new WaveImpactAsphaltCoverWaveConditionsCalculationService().Calculate(calculation, assessmentSection, waveImpactAsphaltCoverFailureMechanism.GeneralInput); // Assert TestHelper.AssertLogMessages(Call, messages => { string[] msgs = messages.ToArray(); Assert.AreEqual(8, msgs.Length); CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); var i = 0; foreach (RoundedDouble waterLevel in GetWaterLevels(calculation, assessmentSection)) { Assert.AreEqual($"Berekening voor waterstand '{waterLevel}' is gestart.", msgs[i + 1]); StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[i + 2]); Assert.AreEqual($"Berekening voor waterstand '{waterLevel}' is beƫindigd.", msgs[i + 3]); i = i + 3; } CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[7]); }); } mockRepository.VerifyAll(); }
public void Validate_ValidInputValidateForeshoreProfile_ReturnsTrueAndLogsValidationStartAndEnd(ForeshoreCalculationType calculationType) { // Setup var isValid = false; WaveConditionsInput input = GetDefaultValidationInput(); switch (calculationType) { case ForeshoreCalculationType.NoForeshore: input.ForeshoreProfile = null; input.UseBreakWater = false; input.UseForeshore = false; input.Orientation = (RoundedDouble)0; break; case ForeshoreCalculationType.ForeshoreWithoutBreakWater: input.ForeshoreProfile = new TestForeshoreProfile(); input.UseBreakWater = false; break; case ForeshoreCalculationType.ForeshoreWithValidBreakWater: break; } // Call void Call() => isValid = WaveConditionsCalculationServiceBase.Validate(input, GetValidAssessmentLevel(), GetValidHydraulicBoundaryDatabase()); // Assert TestHelper.AssertLogMessages(Call, messages => { string[] msgs = messages.ToArray(); Assert.AreEqual(2, msgs.Length); CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]); CalculationServiceTestHelper.AssertValidationEndMessage(msgs[1]); }); Assert.IsTrue(isValid); }
public void Calculate_ValidCalculationInputAndForeshoreWithValidBreakWater_LogStartAndEndAndReturnOutput(ForeshoreCalculationType calculationType) { // Setup var failureMechanism = new HeightStructuresFailureMechanism(); var mockRepository = new MockRepository(); IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mockRepository); var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>(); calculatorFactory.Expect(cf => cf.CreateStructuresCalculator <StructuresOvertoppingCalculationInput>(null)) .IgnoreArguments() .Return(new TestStructuresCalculator <StructuresOvertoppingCalculationInput>()); mockRepository.ReplayAll(); var calculation = new TestHeightStructuresCalculationScenario { InputParameters = { HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), ForeshoreProfile = new TestForeshoreProfile(true), UseBreakWater = true, UseForeshore = true } }; switch (calculationType) { case ForeshoreCalculationType.NoForeshore: calculation.InputParameters.ForeshoreProfile = null; calculation.InputParameters.UseForeshore = false; calculation.InputParameters.UseBreakWater = false; break; case ForeshoreCalculationType.ForeshoreWithoutBreakWater: calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); calculation.InputParameters.UseBreakWater = false; break; case ForeshoreCalculationType.ForeshoreWithValidBreakWater: break; } // Call using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { Action call = () => new HeightStructuresCalculationService().Calculate(calculation, failureMechanism.GeneralInput, CreateCalculationSettings()); // Assert TestHelper.AssertLogMessages(call, messages => { string[] msgs = messages.ToArray(); Assert.AreEqual(3, msgs.Length); CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); StringAssert.StartsWith("Hoogte kunstwerk berekening is uitgevoerd op de tijdelijke locatie" + "" + "", msgs[1]); CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[2]); }); Assert.IsNotNull(calculation.Output); } mockRepository.VerifyAll(); }