Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/StabilityPointStructuresDataSynchronizationServiceTest.cs =================================================================== diff -u -rc964c048005d93b097a1e6a817dace95b293040f -r7618e47c7ff0d09102d56e2c25545f57a4269352 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/StabilityPointStructuresDataSynchronizationServiceTest.cs (.../StabilityPointStructuresDataSynchronizationServiceTest.cs) (revision c964c048005d93b097a1e6a817dace95b293040f) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/StabilityPointStructuresDataSynchronizationServiceTest.cs (.../StabilityPointStructuresDataSynchronizationServiceTest.cs) (revision 7618e47c7ff0d09102d56e2c25545f57a4269352) @@ -56,11 +56,13 @@ .ToArray(); // Call - IEnumerable> affectedItems = - StabilityPointStructuresDataSynchronizationService.ClearAllCalculationOutput(failureMechanism); + IEnumerable affectedItems = StabilityPointStructuresDataSynchronizationService.ClearAllCalculationOutput(failureMechanism); // Assert - Assert.IsFalse(failureMechanism.Calculations.Any(c => c.HasOutput)); + // Note: To make sure the clear is performed regardless of what is done with + // the return result, no ToArray() should not be called before these assertions: + Assert.IsTrue(failureMechanism.Calculations.All(c => !c.HasOutput)); + CollectionAssert.AreEquivalent(expectedAffectedCalculations, affectedItems); } @@ -89,8 +91,11 @@ StabilityPointStructuresDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(failureMechanism); // Assert - Assert.IsFalse(failureMechanism.Calculations.Cast>() - .Any(c => c.InputParameters.HydraulicBoundaryLocation != null || c.HasOutput)); + // Note: To make sure the clear is performed regardless of what is done with + // the return result, no ToArray() should not be called before these assertions: + Assert.IsTrue(failureMechanism.Calculations.Cast>() + .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + CollectionAssert.AreEquivalent(expectedAffectedCalculations, affectedItems); } @@ -112,23 +117,23 @@ StabilityPointStructuresFailureMechanism failureMechanism = CreateFullyConfiguredFailureMechanism(); // Call - IObservable[] observables = StabilityPointStructuresDataSynchronizationService.ClearReferenceLineDependentData(failureMechanism).ToArray(); + IEnumerable observables = StabilityPointStructuresDataSynchronizationService.ClearReferenceLineDependentData(failureMechanism); // Assert - Assert.AreEqual(4, observables.Length); - + // Note: To make sure the clear is performed regardless of what is done with + // the return result, no ToArray() should not be called before these assertions: CollectionAssert.IsEmpty(failureMechanism.Sections); CollectionAssert.IsEmpty(failureMechanism.SectionResults); - CollectionAssert.Contains(observables, failureMechanism); - CollectionAssert.IsEmpty(failureMechanism.CalculationsGroup.Children); - CollectionAssert.Contains(observables, failureMechanism.CalculationsGroup); - CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles); - CollectionAssert.Contains(observables, failureMechanism.ForeshoreProfiles); - CollectionAssert.IsEmpty(failureMechanism.StabilityPointStructures); - CollectionAssert.Contains(observables, failureMechanism.StabilityPointStructures); + + IObservable[] array = observables.ToArray(); + Assert.AreEqual(4, array.Length); + CollectionAssert.Contains(array, failureMechanism); + CollectionAssert.Contains(array, failureMechanism.CalculationsGroup); + CollectionAssert.Contains(array, failureMechanism.ForeshoreProfiles); + CollectionAssert.Contains(array, failureMechanism.StabilityPointStructures); } private static StabilityPointStructuresFailureMechanism CreateFullyConfiguredFailureMechanism()