public void ClearAllCalculationOutputWithoutManualAssessmentLevel_FailureMechanismNull_ThrowsArgumentNullException() { // Call void Call() => MacroStabilityInwardsDataSynchronizationService.ClearAllCalculationOutputWithoutManualAssessmentLevel(null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("failureMechanism", exception.ParamName); }
public void ClearAllCalculationOutputWithoutManualAssessmentLevel_WithVariousCalculations_ClearsCalculationsOutputAndReturnsAffectedCalculations() { // Setup var failureMechanism = new MacroStabilityInwardsFailureMechanism(); failureMechanism.CalculationsGroup.Children.AddRange(new[] { new MacroStabilityInwardsCalculationScenario(), new MacroStabilityInwardsCalculationScenario { InputParameters = { UseAssessmentLevelManualInput = true }, Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() }, new MacroStabilityInwardsCalculationScenario { Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() } }); MacroStabilityInwardsCalculationScenario[] expectedAffectedCalculations = failureMechanism.Calculations .OfType <MacroStabilityInwardsCalculationScenario>() .Where(c => !c.InputParameters.UseAssessmentLevelManualInput && c.HasOutput) .ToArray(); // Call IEnumerable <IObservable> affectedItems = MacroStabilityInwardsDataSynchronizationService.ClearAllCalculationOutputWithoutManualAssessmentLevel(failureMechanism); // Assert // Note: To make sure the clear is performed regardless of what is done with // the return result, no ToArray() should be called before these assertions: Assert.IsTrue(failureMechanism.Calculations .OfType <MacroStabilityInwardsCalculationScenario>() .Where(c => !c.InputParameters.UseAssessmentLevelManualInput) .All(c => !c.HasOutput)); CollectionAssert.AreEquivalent(expectedAffectedCalculations, affectedItems); }