public void RemoveAllDikeProfile_DikeProfilesNull_ThrowsArgumentNullException() { // Call void Call() => GrassCoverErosionInwardsDataSynchronizationService.RemoveAllDikeProfiles( Enumerable.Empty <GrassCoverErosionInwardsCalculation>(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("dikeProfiles", exception.ParamName); }
public void RemoveAllDikeProfile_CalculationsNull_ThrowsArgumentNullException() { // Call void Call() => GrassCoverErosionInwardsDataSynchronizationService.RemoveAllDikeProfiles( null, new DikeProfileCollection()); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("calculations", exception.ParamName); }
public void RemoveAllDikeProfiles_FullyConfiguredFailureMechanism_RemovesAllDikeProfilesAndDependentData() { // Setup GrassCoverErosionInwardsFailureMechanism failureMechanism = CreateFullyConfiguredFailureMechanism(); GrassCoverErosionInwardsCalculation[] calculationsWithDikeProfiles = failureMechanism.Calculations .Cast <GrassCoverErosionInwardsCalculation>() .Where(calc => calc.InputParameters.DikeProfile != null) .ToArray(); GrassCoverErosionInwardsCalculation[] calculationsWithDikeProfilesAndOutput = calculationsWithDikeProfiles.Where(calc => calc.HasOutput).ToArray(); // Precondition CollectionAssert.IsNotEmpty(calculationsWithDikeProfiles); // Call IEnumerable <IObservable> affectedObjects = GrassCoverErosionInwardsDataSynchronizationService.RemoveAllDikeProfiles( failureMechanism.Calculations.Cast <GrassCoverErosionInwardsCalculation>(), failureMechanism.DikeProfiles); // 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.IsEmpty(failureMechanism.DikeProfiles); foreach (GrassCoverErosionInwardsCalculation calculation in calculationsWithDikeProfilesAndOutput) { Assert.IsFalse(calculation.HasOutput); } IEnumerable <IObservable> expectedAffectedObjects = calculationsWithDikeProfiles.Select(calc => calc.InputParameters) .Cast <IObservable>() .Concat(calculationsWithDikeProfilesAndOutput) .Concat(new IObservable[] { failureMechanism.DikeProfiles }); CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects); }
protected override IEnumerable <IObservable> ClearData() { return(GrassCoverErosionInwardsDataSynchronizationService.RemoveAllDikeProfiles( FailureMechanism.Calculations.Cast <GrassCoverErosionInwardsCalculation>(), FailureMechanism.DikeProfiles)); }