private void Calculate(GrassCoverErosionOutwardsWaveConditionsCalculationContext context) { ActivityProgressDialogRunner.Run(Gui.MainWindow, GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(context.WrappedData, context.FailureMechanism, context.AssessmentSection)); }
public void Cancel_WhenPerformingCalculation_CurrentCalculationForWaterLevelCompletesAndSubsequentCalculationsDidNotRun() { // Setup AssessmentSectionStub assessmentSection = CreateAssessmentSection(); ConfigureAssessmentSectionWithHydraulicBoundaryOutput(assessmentSection); GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); CalculatableActivity activity = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation, failureMechanism, assessmentSection); var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>(); calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(null)) .IgnoreArguments() .Return(new TestWaveConditionsCosineCalculator()); mockRepository.ReplayAll(); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { activity.ProgressChanged += (sender, args) => { if (activity.State != ActivityState.Canceled) { // Call activity.Cancel(); } }; // Assert TestHelper.AssertLogMessages(() => activity.Run(), messages => { string[] msgs = messages.ToArray(); RoundedDouble firstWaterLevel = GetWaterLevels(calculation, assessmentSection).First(); Assert.AreEqual(10, msgs.Length); Assert.AreEqual($"Golfcondities berekenen voor '{calculation.Name}' is gestart.", msgs[0]); CalculationServiceTestHelper.AssertValidationStartMessage(msgs[1]); CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]); CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[3]); Assert.AreEqual("Berekening voor golfoploop is gestart.", msgs[4]); Assert.AreEqual($"Berekening voor waterstand '{firstWaterLevel}' is gestart.", msgs[5]); StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[6]); Assert.AreEqual($"Berekening voor waterstand '{firstWaterLevel}' is beëindigd.", msgs[7]); Assert.AreEqual("Berekening voor golfoploop is beëindigd.", msgs[8]); CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[9]); }); Assert.AreEqual(ActivityState.Canceled, activity.State); Assert.IsNull(calculation.Output); } mockRepository.VerifyAll(); }
public void CreateCalculationActivity_WithValidCalculation_ReturnsGrassCoverErosionOutwardsWaveConditionsCalculationActivityWithParametersSet() { // Setup GrassCoverErosionOutwardsFailureMechanism failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); var assessmentSection = new AssessmentSectionStub(); HydraulicBoundaryDatabase hydraulicBoundaryDatabase = assessmentSection.HydraulicBoundaryDatabase; hydraulicBoundaryDatabase.FilePath = validFilePath; var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName 1"); assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] { hydraulicBoundaryLocation }, true); GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(hydraulicBoundaryLocation); // Call CalculatableActivity activity = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation, failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf <GrassCoverErosionOutwardsWaveConditionsCalculationActivity>(activity); AssertGrassCoverErosionOutwardsWaveConditionsCalculationActivity( activity, calculation, assessmentSection.WaterLevelCalculationsForSignalFloodingProbability.Single().Output.Result, hydraulicBoundaryDatabase); }
/// <summary> /// Creates a collection of <see cref="CalculatableActivity"/> for all relevant hydraulic load calculations /// in the given <see cref="AssessmentSection"/>. /// </summary> /// <param name="assessmentSection">The assessment section to create the activities for.</param> /// <returns>A collection of <see cref="CalculatableActivity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="assessmentSection"/> is <c>null</c>.</exception> public static IEnumerable <CalculatableActivity> CreateHydraulicLoadCalculationActivities(AssessmentSection assessmentSection) { if (assessmentSection == null) { throw new ArgumentNullException(nameof(assessmentSection)); } var activities = new List <CalculatableActivity>(); activities.AddRange(AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactory.CreateHydraulicBoundaryLocationCalculationActivities( assessmentSection)); activities.AddRange(StabilityStoneCoverWaveConditionsCalculationActivityFactory.CreateCalculationActivities( assessmentSection.StabilityStoneCover, assessmentSection)); activities.AddRange(WaveImpactAsphaltCoverWaveConditionsCalculationActivityFactory.CreateCalculationActivities( assessmentSection.WaveImpactAsphaltCover, assessmentSection)); activities.AddRange(GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivities( assessmentSection.GrassCoverErosionOutwards.CalculationsGroup, assessmentSection.GrassCoverErosionOutwards, assessmentSection)); activities.AddRange(DuneLocationCalculationActivityFactory.CreateCalculationActivities( assessmentSection.DuneErosion, assessmentSection)); return(activities); }
private ContextMenuStrip HydraulicLoadsStateFailureMechanismContextMenuStrip(HydraulicLoadsStateFailureMechanismContext context, object parentData, TreeViewControl treeViewControl) { var builder = new RiskeerContextMenuBuilder(Gui.Get(context, treeViewControl)); IAssessmentSection assessmentSection = context.Parent; var calculateAllItem = new StrictContextMenuItem( RiskeerCommonFormsResources.Calculate_All, RiskeerCommonFormsResources.Calculate_All_ToolTip, RiskeerCommonFormsResources.CalculateAllIcon, (sender, args) => { ActivityProgressDialogRunner.Run( Gui.MainWindow, GrassCoverErosionOutwardsCalculationActivityFactory .CreateWaveConditionsCalculationActivities(context.WrappedData.CalculationsGroup, context.WrappedData, assessmentSection)); }); SetHydraulicsMenuItemEnabledStateAndTooltip(assessmentSection, calculateAllItem); return(builder.AddOpenItem() .AddSeparator() .AddCustomItem(calculateAllItem) .AddSeparator() .AddCollapseAllItem() .AddExpandAllItem() .AddSeparator() .AddPropertiesItem() .Build()); }
public void CreateWaveConditionsCalculationActivitiesForCalculationGroup_AssessmentSectionNull_ThrowsArgumentNullException() { // Call void Call() => GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivities( new CalculationGroup(), new GrassCoverErosionOutwardsFailureMechanism(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("assessmentSection", exception.ParamName); }
public void CreateCalculationActivity_AssessmentSectionNull_ThrowsArgumentNullException() { // Setup var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); // Call void Call() => GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation, failureMechanism, null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("assessmentSection", exception.ParamName); }
public void Run_Always_SetProgressTexts() { // Setup AssessmentSectionStub assessmentSection = CreateAssessmentSection(); ConfigureAssessmentSectionWithHydraulicBoundaryOutput(assessmentSection); GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); CalculatableActivity activity = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation, failureMechanism, assessmentSection); int nrOfCalculators = GetNrOfCalculators(calculation, assessmentSection); var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>(); calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(null)) .IgnoreArguments() .Return(new TestWaveConditionsCosineCalculator()) .Repeat .Times(nrOfCalculators); mockRepository.ReplayAll(); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { var progressTexts = new List <string>(); activity.ProgressChanged += (sender, args) => progressTexts.Add(activity.ProgressText); // Call activity.Run(); // Assert RoundedDouble[] waterLevels = GetWaterLevels(calculation, assessmentSection).ToArray(); int totalSteps = waterLevels.Length * 2; for (var i = 0; i < totalSteps; i++) { string calculationType = i < waterLevels.Length ? "golfoploop" : "golfklap"; var text = $"Stap {i + 1} van {totalSteps} | Waterstand '{waterLevels[i % waterLevels.Length]}' [m+NAP] voor {calculationType} berekenen."; Assert.AreEqual(text, progressTexts[i]); } } mockRepository.VerifyAll(); }
public void CreateWaveConditionsCalculationActivitiesForCalculationGroup_FailureMechanismNull_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); // Call void Call() => GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivities( new CalculationGroup(), null, assessmentSection); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("failureMechanism", exception.ParamName); mocks.VerifyAll(); }
public void Run_WhenCanceled_OutputNull() { // Setup AssessmentSectionStub assessmentSection = CreateAssessmentSection(); ConfigureAssessmentSectionWithHydraulicBoundaryOutput(assessmentSection); GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); CalculatableActivity activity = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation, failureMechanism, assessmentSection); var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>(); calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(null)) .IgnoreArguments() .Return(new TestWaveConditionsCosineCalculator()); mockRepository.ReplayAll(); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { activity.ProgressChanged += (sender, args) => { if (activity.State != ActivityState.Canceled) { activity.Cancel(); } }; activity.Run(); // Call activity.Finish(); // Assert Assert.AreEqual(ActivityState.Canceled, activity.State); Assert.IsNull(calculation.Output); } mockRepository.VerifyAll(); }
public void Run_HydraulicBoundaryDatabaseWithUsePreprocessorFalse_CreateWaveConditionsCosineCalculatorAsExpected() { // Setup AssessmentSectionStub assessmentSection = CreateAssessmentSection(); ConfigureAssessmentSectionWithHydraulicBoundaryOutput(assessmentSection); GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.CanUsePreprocessor = true; assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.UsePreprocessor = false; assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.PreprocessorDirectory = "InvalidPreprocessorDirectory"; var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); CalculatableActivity activity = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation, failureMechanism, assessmentSection); int nrOfCalculators = GetNrOfCalculators(calculation, assessmentSection); var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>(); calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(Arg <HydraRingCalculationSettings> .Is.NotNull)) .WhenCalled(invocation => { HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings( HydraulicBoundaryCalculationSettingsFactory.CreateSettings(assessmentSection.HydraulicBoundaryDatabase), (HydraRingCalculationSettings)invocation.Arguments[0]); }) .Return(new TestWaveConditionsCosineCalculator()) .Repeat .Times(nrOfCalculators); mockRepository.ReplayAll(); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call activity.Run(); } // Assert mockRepository.VerifyAll(); }
public void Run_CalculationWithInvalidHydraulicBoundaryDatabaseFilePath_DoesNotPerformCalculationAndLogsError() { // Setup string invalidFilePath = Path.Combine(testDataPath, "NonExisting.sqlite"); AssessmentSectionStub assessmentSection = CreateAssessmentSection(); assessmentSection.HydraulicBoundaryDatabase.FilePath = invalidFilePath; ConfigureAssessmentSectionWithHydraulicBoundaryOutput(assessmentSection); GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>(); mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); CalculatableActivity activity = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation, failureMechanism, assessmentSection); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call void Call() => activity.Run(); // Assert TestHelper.AssertLogMessages(Call, messages => { string[] msgs = messages.ToArray(); Assert.AreEqual(4, msgs.Length); Assert.AreEqual($"Golfcondities berekenen voor '{calculation.Name}' is gestart.", msgs[0]); CalculationServiceTestHelper.AssertValidationStartMessage(msgs[1]); Assert.AreEqual("Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt. " + $"Fout bij het lezen van bestand '{invalidFilePath}': het bestand bestaat niet.", msgs[2]); CalculationServiceTestHelper.AssertValidationEndMessage(msgs[3]); }); Assert.AreEqual(ActivityState.Failed, activity.State); } mockRepository.VerifyAll(); }
public void Run_CalculationFailed_OutputNull(bool endInFailure, string lastErrorFileContent) { // Setup AssessmentSectionStub assessmentSection = CreateAssessmentSection(); ConfigureAssessmentSectionWithHydraulicBoundaryOutput(assessmentSection); GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); CalculatableActivity activity = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation, failureMechanism, assessmentSection); var waveConditionsCosineCalculator = new TestWaveConditionsCosineCalculator { EndInFailure = endInFailure, LastErrorFileContent = lastErrorFileContent }; int nrOfCalculators = GetWaterLevels(calculation, assessmentSection).Count(); var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>(); calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(null)) .IgnoreArguments() .Return(waveConditionsCosineCalculator) .Repeat .Times(nrOfCalculators); mockRepository.ReplayAll(); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call activity.Run(); // Assert Assert.IsNull(calculation.Output); } mockRepository.VerifyAll(); }
public void Run_CalculationWithInvalidPreprocessorDirectory_DoesNotPerformCalculationAndLogsError() { // Setup AssessmentSectionStub assessmentSection = CreateAssessmentSection(); ConfigureAssessmentSectionWithHydraulicBoundaryOutput(assessmentSection); GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.CanUsePreprocessor = true; assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.UsePreprocessor = true; assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.PreprocessorDirectory = "NonExistingPreprocessorDirectory"; var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>(); mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); CalculatableActivity activity = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation, failureMechanism, assessmentSection); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call void Call() => activity.Run(); // Assert TestHelper.AssertLogMessages(Call, messages => { string[] msgs = messages.ToArray(); Assert.AreEqual(4, msgs.Length); Assert.AreEqual($"Golfcondities berekenen voor '{calculation.Name}' is gestart.", msgs[0]); CalculationServiceTestHelper.AssertValidationStartMessage(msgs[1]); Assert.AreEqual("De bestandsmap waar de preprocessor bestanden opslaat is ongeldig. De bestandsmap bestaat niet.", msgs[2]); CalculationServiceTestHelper.AssertValidationEndMessage(msgs[3]); }); Assert.AreEqual(ActivityState.Failed, activity.State); } mockRepository.VerifyAll(); }
public void Finish_VariousCalculationEndStates_NotifiesObserversOfCalculation(bool endInFailure) { // Setup var mockRepository = new MockRepository(); var observer = mockRepository.StrictMock <IObserver>(); observer.Expect(o => o.UpdateObserver()); var calculatorFactory = mockRepository.Stub <IHydraRingCalculatorFactory>(); calculatorFactory.Stub(cf => cf.CreateWaveConditionsCosineCalculator(null)) .IgnoreArguments() .Return(new TestWaveConditionsCosineCalculator { EndInFailure = endInFailure }); mockRepository.ReplayAll(); AssessmentSectionStub assessmentSection = CreateAssessmentSection(); ConfigureAssessmentSectionWithHydraulicBoundaryOutput(assessmentSection); GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); calculation.Attach(observer); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); CalculatableActivity activity = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation, failureMechanism, assessmentSection); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { activity.Run(); } // Call activity.Finish(); // Assert mockRepository.VerifyAll(); }
public void CreateWaveConditionsCalculationActivitiesForCalculationGroup_WithValidCalculations_ReturnsGrassCoverErosionOutwardsWaveConditionsCalculationActivitiesWithParametersSet() { // Setup GrassCoverErosionOutwardsFailureMechanism failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); var assessmentSection = new AssessmentSectionStub(); HydraulicBoundaryDatabase hydraulicBoundaryDatabase = assessmentSection.HydraulicBoundaryDatabase; hydraulicBoundaryDatabase.FilePath = validFilePath; var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName 1"); assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] { hydraulicBoundaryLocation }, true); GrassCoverErosionOutwardsWaveConditionsCalculation calculation1 = CreateValidCalculation(hydraulicBoundaryLocation); GrassCoverErosionOutwardsWaveConditionsCalculation calculation2 = CreateValidCalculation(hydraulicBoundaryLocation); var calculations = new CalculationGroup { Children = { calculation1, calculation2 } }; // Call IEnumerable <CalculatableActivity> activities = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivities( calculations, failureMechanism, assessmentSection); // Assert CollectionAssert.AllItemsAreInstancesOfType(activities, typeof(GrassCoverErosionOutwardsWaveConditionsCalculationActivity)); Assert.AreEqual(2, activities.Count()); RoundedDouble assessmentLevel = assessmentSection.WaterLevelCalculationsForSignalFloodingProbability.Single().Output.Result; AssertGrassCoverErosionOutwardsWaveConditionsCalculationActivity(activities.First(), calculation1, assessmentLevel, hydraulicBoundaryDatabase); AssertGrassCoverErosionOutwardsWaveConditionsCalculationActivity(activities.ElementAt(1), calculation2, assessmentLevel, hydraulicBoundaryDatabase); }
public void Run_CalculationPerformed_SetsOutput() { // Setup AssessmentSectionStub assessmentSection = CreateAssessmentSection(); ConfigureAssessmentSectionWithHydraulicBoundaryOutput(assessmentSection); GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); CalculatableActivity activity = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation, failureMechanism, assessmentSection); int nrOfCalculators = GetNrOfCalculators(calculation, assessmentSection); var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>(); calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(null)) .IgnoreArguments() .Return(new TestWaveConditionsCosineCalculator()) .Repeat .Times(nrOfCalculators); mockRepository.ReplayAll(); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call activity.Run(); // Assert Assert.IsNotNull(calculation.Output); Assert.AreEqual(3, calculation.Output.WaveRunUpOutput.Count()); } mockRepository.VerifyAll(); }
public void Run_Always_InputPropertiesCorrectlySentToService(BreakWaterType breakWaterType) { // Setup AssessmentSectionStub assessmentSection = CreateAssessmentSection(); ConfigureAssessmentSectionWithHydraulicBoundaryOutput(assessmentSection); GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); calculation.InputParameters.BreakWater.Type = breakWaterType; var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); CalculatableActivity activity = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation, failureMechanism, assessmentSection); var waveConditionsCosineCalculator = new TestWaveConditionsCosineCalculator(); RoundedDouble[] waterLevels = GetWaterLevels(calculation, assessmentSection).ToArray(); int nrOfCalculators = GetNrOfCalculators(calculation, assessmentSection); var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>(); calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(null)) .IgnoreArguments() .Return(waveConditionsCosineCalculator) .Repeat .Times(nrOfCalculators); mockRepository.ReplayAll(); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call activity.Run(); // Assert WaveConditionsCosineCalculationInput[] waveConditionsInputs = waveConditionsCosineCalculator.ReceivedInputs.ToArray(); Assert.AreEqual(nrOfCalculators, waveConditionsInputs.Length); WaveConditionsInput input = calculation.InputParameters; double targetProbability = assessmentSection.FailureMechanismContribution.MaximumAllowableFloodingProbability; var waterLevelIndex = 0; GeneralGrassCoverErosionOutwardsInput generalInput = failureMechanism.GeneralInput; for (var i = 0; i < waveConditionsInputs.Length / 2; i++) { var expectedInput = new WaveConditionsCosineCalculationInput(1, input.Orientation, input.HydraulicBoundaryLocation.Id, targetProbability, input.ForeshoreProfile.Geometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)), new HydraRingBreakWater(BreakWaterTypeHelper.GetHydraRingBreakWaterType(breakWaterType), input.BreakWater.Height), waterLevels[waterLevelIndex++], generalInput.GeneralWaveRunUpWaveConditionsInput.A, generalInput.GeneralWaveRunUpWaveConditionsInput.B, generalInput.GeneralWaveRunUpWaveConditionsInput.C); HydraRingDataEqualityHelper.AreEqual(expectedInput, waveConditionsInputs[i]); } waterLevelIndex = 0; for (int i = waveConditionsInputs.Length / 2; i < waveConditionsInputs.Length; i++) { var expectedInput = new WaveConditionsCosineCalculationInput(1, input.Orientation, input.HydraulicBoundaryLocation.Id, targetProbability, input.ForeshoreProfile.Geometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)), new HydraRingBreakWater(BreakWaterTypeHelper.GetHydraRingBreakWaterType(breakWaterType), input.BreakWater.Height), waterLevels[waterLevelIndex++], generalInput.GeneralWaveImpactWaveConditionsInput.A, generalInput.GeneralWaveImpactWaveConditionsInput.B, generalInput.GeneralWaveImpactWaveConditionsInput.C); HydraRingDataEqualityHelper.AreEqual(expectedInput, waveConditionsInputs[i]); } } mockRepository.VerifyAll(); }