public void ClearAllCalculationOutput_FailureMechanismNull_ThrowsArgumentNullException() { // Call void Call() => HeightStructuresDataSynchronizationService.ClearAllCalculationOutput(null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("failureMechanism", exception.ParamName); }
public void ClearAllCalculationOutput_WithOutput_ClearsCalculationsOutput() { // Setup var failureMechanism = new HeightStructuresFailureMechanism(); var calculation1 = new StructuresCalculation <HeightStructuresInput> { Output = new TestStructuresOutput() }; var calculation2 = new StructuresCalculation <HeightStructuresInput> { Output = new TestStructuresOutput() }; var calculation3 = new StructuresCalculation <HeightStructuresInput>(); failureMechanism.CalculationsGroup.Children.Add(calculation1); failureMechanism.CalculationsGroup.Children.Add(calculation2); failureMechanism.CalculationsGroup.Children.Add(calculation3); // Call IEnumerable <IObservable> affectedItems = HeightStructuresDataSynchronizationService.ClearAllCalculationOutput(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 (ICalculation calculation in failureMechanism.Calculations) { Assert.IsFalse(calculation.HasOutput); } CollectionAssert.AreEqual(new[] { calculation1, calculation2 }, affectedItems); }