public void RemoveAllStructures_FailureMechanismNull_ThrowsArgumentNullException() { // Call void Call() => HeightStructuresDataSynchronizationService.RemoveAllStructures(null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("failureMechanism", exception.ParamName); }
protected override IEnumerable <IObservable> ClearData() { return(HeightStructuresDataSynchronizationService.RemoveAllStructures(FailureMechanism)); }
public void RemoveAllStructures_FullyConfiguredFailureMechanism_RemoveAllStructuresAndClearDependentData() { // Setup var failureMechanism = new HeightStructuresFailureMechanism(); var structureA = new TestHeightStructure(new Point2D(0, 0), "A"); var structureB = new TestHeightStructure(new Point2D(2, 2), "B"); failureMechanism.HeightStructures.AddRange(new[] { structureA, structureB }, "path/to/structures"); var calculationWithOutput = new StructuresCalculation <HeightStructuresInput> { Output = new TestStructuresOutput() }; var calculationWithStructureA = new StructuresCalculation <HeightStructuresInput> { InputParameters = { Structure = structureA } }; var calculationWithStructureBAndOutput = new StructuresCalculation <HeightStructuresInput> { InputParameters = { Structure = structureB }, Output = new TestStructuresOutput() }; var calculationWithStructureAAndOutput = new StructuresCalculation <HeightStructuresInput> { InputParameters = { Structure = structureA }, Output = new TestStructuresOutput() }; failureMechanism.CalculationsGroup.Children.AddRange(new[] { calculationWithOutput, calculationWithStructureA, calculationWithStructureBAndOutput, calculationWithStructureAAndOutput }); // Call IEnumerable <IObservable> affectedObjects = HeightStructuresDataSynchronizationService.RemoveAllStructures(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: CollectionAssert.DoesNotContain(failureMechanism.HeightStructures, structureA); Assert.IsNull(calculationWithStructureA.InputParameters.Structure); Assert.IsNull(calculationWithStructureAAndOutput.InputParameters.Structure); Assert.IsNull(calculationWithStructureBAndOutput.InputParameters.Structure); Assert.IsNull(calculationWithStructureAAndOutput.Output); Assert.IsNull(calculationWithStructureBAndOutput.Output); Assert.IsNotNull(calculationWithOutput.Output); IObservable[] expectedAffectedObjects = { calculationWithStructureA.InputParameters, calculationWithStructureAAndOutput, calculationWithStructureAAndOutput.InputParameters, calculationWithStructureBAndOutput, calculationWithStructureBAndOutput.InputParameters, failureMechanism.HeightStructures }; CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects); }