public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_WithoutFailureMechanism_ThrowsArgumentNullException() { // Call void Call() => ClosingStructuresDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("failureMechanism", exception.ParamName); }
public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_CalculationsWithHydraulicBoundaryLocationAndOutput_ClearsHydraulicBoundaryLocationAndCalculationsAndReturnsAffectedObjects() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0); var calculation1 = new StructuresCalculation <ClosingStructuresInput> { InputParameters = { HydraulicBoundaryLocation = hydraulicBoundaryLocation }, Output = new TestStructuresOutput() }; var calculation2 = new StructuresCalculation <ClosingStructuresInput> { InputParameters = { HydraulicBoundaryLocation = hydraulicBoundaryLocation }, Output = new TestStructuresOutput() }; var calculation3 = new StructuresCalculation <ClosingStructuresInput>(); failureMechanism.CalculationsGroup.Children.Add(calculation1); failureMechanism.CalculationsGroup.Children.Add(calculation2); failureMechanism.CalculationsGroup.Children.Add(calculation3); // Call IEnumerable <IObservable> affectedItems = ClosingStructuresDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(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: foreach (StructuresCalculation <ClosingStructuresInput> calculation in failureMechanism.CalculationsGroup.Children.Cast <StructuresCalculation <ClosingStructuresInput> >()) { Assert.IsNull(calculation.InputParameters.HydraulicBoundaryLocation); Assert.IsNull(calculation.Output); } CollectionAssert.AreEquivalent(new IObservable[] { calculation1, calculation1.InputParameters, calculation2, calculation2.InputParameters }, affectedItems); }
public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_CalculationWithoutOutputAndHydraulicBoundaryLocation_ReturnNoAffectedCalculations() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); var calculation1 = new StructuresCalculation <ClosingStructuresInput>(); var calculation2 = new StructuresCalculation <ClosingStructuresInput>(); var calculation3 = new StructuresCalculation <ClosingStructuresInput>(); failureMechanism.CalculationsGroup.Children.Add(calculation1); failureMechanism.CalculationsGroup.Children.Add(calculation2); failureMechanism.CalculationsGroup.Children.Add(calculation3); // Call IEnumerable <IObservable> affectedItems = ClosingStructuresDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(failureMechanism); // Assert CollectionAssert.IsEmpty(affectedItems); }
public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_CalculationsWithOutputAndNoHydraulicBoundaryLocation_ClearsOutputAndReturnsAffectedCalculations() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); var calculation1 = new StructuresCalculation <ClosingStructuresInput> { Output = new TestStructuresOutput() }; var calculation2 = new StructuresCalculation <ClosingStructuresInput> { Output = new TestStructuresOutput() }; var calculation3 = new StructuresCalculation <ClosingStructuresInput>(); failureMechanism.CalculationsGroup.Children.Add(calculation1); failureMechanism.CalculationsGroup.Children.Add(calculation2); failureMechanism.CalculationsGroup.Children.Add(calculation3); // Call IEnumerable <IObservable> affectedItems = ClosingStructuresDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(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: foreach (StructuresCalculation <ClosingStructuresInput> calculation in failureMechanism.CalculationsGroup.Children.Cast <StructuresCalculation <ClosingStructuresInput> >()) { Assert.IsNull(calculation.Output); } CollectionAssert.AreEqual(new[] { calculation1, calculation2 }, affectedItems); }