protected override IEnumerable <IObservable> RemoveObjectAndDependentData(DikeProfile removedObject) { return(GrassCoverErosionInwardsDataSynchronizationService.RemoveDikeProfile( removedObject, FailureMechanism.Calculations.Cast <GrassCoverErosionInwardsCalculation>(), FailureMechanism.DikeProfiles)); }
public void RemoveDikeProfile_DikeProfilesNull_ThrowsArgumentNullException() { // Call void Call() => GrassCoverErosionInwardsDataSynchronizationService.RemoveDikeProfile( DikeProfileTestFactory.CreateDikeProfile(), Enumerable.Empty <GrassCoverErosionInwardsCalculation>(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("dikeProfiles", exception.ParamName); }
public void RemoveDikeProfile_CalculationsNull_ThrowsArgumentNullException() { // Call void Call() => GrassCoverErosionInwardsDataSynchronizationService.RemoveDikeProfile( DikeProfileTestFactory.CreateDikeProfile(), null, new DikeProfileCollection()); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("calculations", exception.ParamName); }
public void RemoveDikeProfile_DikeProfileToRemove_ThrowsArgumentNullException() { // Call void Call() => GrassCoverErosionInwardsDataSynchronizationService.RemoveDikeProfile( null, Enumerable.Empty <GrassCoverErosionInwardsCalculation>(), new DikeProfileCollection()); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("dikeProfileToRemove", exception.ParamName); }
public void RemoveDikeProfile_VariousCalculationConfigurations_ReturnsOnlyAffectedCalculations() { // Setup GrassCoverErosionInwardsFailureMechanism failureMechanism = CreateFullyConfiguredFailureMechanism(); DikeProfile profileToBeCleared = failureMechanism.DikeProfiles[0]; DikeProfile profileToKeep = failureMechanism.DikeProfiles[1]; GrassCoverErosionInwardsCalculation[] affectedCalculationsWithProfile = failureMechanism.Calculations .Cast <GrassCoverErosionInwardsCalculation>() .Where(calc => ReferenceEquals(profileToBeCleared, calc.InputParameters.DikeProfile)) .ToArray(); GrassCoverErosionInwardsCalculation[] affectedCalculationsWithOutput = affectedCalculationsWithProfile.Where(calc => calc.HasOutput).ToArray(); GrassCoverErosionInwardsCalculation[] unaffectedCalculationsWithProfile = failureMechanism.Calculations .Cast <GrassCoverErosionInwardsCalculation>() .Where(calc => ReferenceEquals(profileToKeep, calc.InputParameters.DikeProfile)) .ToArray(); // Precondition CollectionAssert.IsNotEmpty(affectedCalculationsWithOutput); // Call IEnumerable <IObservable> affectedObjects = GrassCoverErosionInwardsDataSynchronizationService.RemoveDikeProfile(profileToBeCleared, failureMechanism.Calculations.Cast <GrassCoverErosionInwardsCalculation>(), failureMechanism.DikeProfiles); // Assert CollectionAssert.DoesNotContain(failureMechanism.DikeProfiles, profileToBeCleared); Assert.True(affectedCalculationsWithOutput.All(calc => !calc.HasOutput)); Assert.True(unaffectedCalculationsWithProfile.All(calc => calc.InputParameters.DikeProfile != null)); IEnumerable <IObservable> expectedAffectedObjects = affectedCalculationsWithProfile.Select(calc => calc.InputParameters) .Cast <IObservable>() .Concat(affectedCalculationsWithOutput) .Concat(new IObservable[] { failureMechanism.DikeProfiles }); CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects); }