public void SetPropertyValueAfterConfirmation_CalculationsForTargetProbabilityWithAndWithoutOutput_AllCalculationOutputClearedAndReturnsAllAffectedObjects() { // Setup DialogBoxHandler = (name, wnd) => { var tester = new MessageBoxTester(wnd); tester.ClickOk(); }; AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(); HydraulicBoundaryLocationCalculationsForTargetProbability calculationsForTargetProbability = assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities .First(); var waveConditionsCalculations = new List <ICalculation <WaveConditionsInput> >(); waveConditionsCalculations.AddRange(assessmentSection.GrassCoverErosionOutwards.Calculations .Cast <GrassCoverErosionOutwardsWaveConditionsCalculation>()); waveConditionsCalculations.AddRange(assessmentSection.StabilityStoneCover.Calculations .Cast <StabilityStoneCoverWaveConditionsCalculation>()); waveConditionsCalculations.AddRange(assessmentSection.WaveImpactAsphaltCover.Calculations .Cast <WaveImpactAsphaltCoverWaveConditionsCalculation>()); waveConditionsCalculations.ForEachElementDo(c => { c.InputParameters.WaterLevelType = WaveConditionsInputWaterLevelType.UserDefinedTargetProbability; c.InputParameters.CalculationsTargetProbability = calculationsForTargetProbability; }); var expectedAffectedObjects = new List <IObservable> { calculationsForTargetProbability }; expectedAffectedObjects.AddRange(calculationsForTargetProbability.HydraulicBoundaryLocationCalculations.Where(c => c.HasOutput)); expectedAffectedObjects.AddRange(waveConditionsCalculations.Where(c => c.HasOutput)); var handler = new WaterLevelHydraulicBoundaryLocationCalculationsForTargetProbabilityChangeHandler(calculationsForTargetProbability, assessmentSection); IEnumerable <IObservable> affectedObjects = null; // Call void Call() => affectedObjects = handler.SetPropertyValueAfterConfirmation(() => {}); // Assert var expectedMessages = new[] { "Alle bijbehorende hydraulische belastingen zijn verwijderd." }; TestHelper.AssertLogMessagesAreGenerated(Call, expectedMessages, 1); CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects); CollectionAssert.IsEmpty(calculationsForTargetProbability.HydraulicBoundaryLocationCalculations.Where(c => c.HasOutput)); CollectionAssert.IsEmpty(waveConditionsCalculations.Where(c => c.HasOutput)); }
public void SetPropertyValueAfterConfirmation_CalculationsForTargetProbabilityWithoutOutput_ReturnsOnlyCalculationsForTargetProbability() { // Setup AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(); HydraulicBoundaryLocationCalculationsForTargetProbability calculationsForTargetProbability = assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities .First(); var waveConditionsCalculations = new List <ICalculation <WaveConditionsInput> >(); waveConditionsCalculations.AddRange(assessmentSection.GrassCoverErosionOutwards.Calculations .Cast <GrassCoverErosionOutwardsWaveConditionsCalculation>()); waveConditionsCalculations.AddRange(assessmentSection.StabilityStoneCover.Calculations .Cast <StabilityStoneCoverWaveConditionsCalculation>()); waveConditionsCalculations.AddRange(assessmentSection.WaveImpactAsphaltCover.Calculations .Cast <WaveImpactAsphaltCoverWaveConditionsCalculation>()); waveConditionsCalculations.ForEachElementDo(c => { c.InputParameters.WaterLevelType = WaveConditionsInputWaterLevelType.UserDefinedTargetProbability; c.InputParameters.CalculationsTargetProbability = calculationsForTargetProbability; c.ClearOutput(); }); calculationsForTargetProbability.HydraulicBoundaryLocationCalculations.ForEachElementDo(c => c.Output = null); var handler = new WaterLevelHydraulicBoundaryLocationCalculationsForTargetProbabilityChangeHandler( calculationsForTargetProbability, assessmentSection); HydraulicBoundaryLocationCalculationsForTargetProbability[] expectedAffectedObjects = { calculationsForTargetProbability }; IEnumerable <IObservable> affectedObjects = null; // Call void Call() => affectedObjects = handler.SetPropertyValueAfterConfirmation(() => {}); // Assert TestHelper.AssertLogMessagesCount(Call, 0); CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects); }