public void RemoveStructure_FailureMechanismNull_ThrowsArgumentNullException() { // Call void Call() => ClosingStructuresDataSynchronizationService.RemoveStructure(new TestClosingStructure(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("failureMechanism", exception.ParamName); }
public void RemoveStructure_FullyConfiguredFailureMechanism_RemovesStructureAndClearsDependentData() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); var structureToRemove = new TestClosingStructure(new Point2D(0, 0), "id1"); var structureToKeep = new TestClosingStructure(new Point2D(2, 2), "id2"); failureMechanism.ClosingStructures.AddRange(new[] { structureToRemove, structureToKeep }, "path/to/structures"); var calculationWithOutput = new TestClosingStructuresCalculationScenario { Output = new TestStructuresOutput() }; var calculationWithStructureToRemove = new TestClosingStructuresCalculationScenario { InputParameters = { Structure = structureToRemove } }; var calculationWithStructureToKeepAndOutput = new TestClosingStructuresCalculationScenario { InputParameters = { Structure = structureToKeep }, Output = new TestStructuresOutput() }; var calculationWithStructureToRemoveAndOutput = new TestClosingStructuresCalculationScenario { InputParameters = { Structure = structureToRemove }, Output = new TestStructuresOutput() }; failureMechanism.CalculationsGroup.Children.AddRange(new[] { calculationWithOutput, calculationWithStructureToRemove, calculationWithStructureToKeepAndOutput, calculationWithStructureToRemoveAndOutput }); // Call IEnumerable <IObservable> affectedObjects = ClosingStructuresDataSynchronizationService.RemoveStructure( structureToRemove, 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.ClosingStructures, structureToRemove); Assert.IsNull(calculationWithStructureToRemove.InputParameters.Structure); Assert.IsNull(calculationWithStructureToRemoveAndOutput.InputParameters.Structure); Assert.IsNull(calculationWithStructureToRemoveAndOutput.Output); Assert.IsNotNull(calculationWithOutput.Output); Assert.IsNotNull(calculationWithStructureToKeepAndOutput.Output); Assert.IsNotNull(calculationWithStructureToKeepAndOutput.InputParameters.Structure); IObservable[] expectedAffectedObjects = { calculationWithStructureToRemove.InputParameters, calculationWithStructureToRemoveAndOutput, calculationWithStructureToRemoveAndOutput.InputParameters, failureMechanism.ClosingStructures }; CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects); }
protected override IEnumerable <IObservable> RemoveObjectAndDependentData(ClosingStructure removedObject) { return(ClosingStructuresDataSynchronizationService.RemoveStructure(removedObject, FailureMechanism)); }