public void ClearWaveConditionsCalculationOutputAndRemoveTargetProbability_CalculationsForTargetProbabilityNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => WaveConditionsDataSynchronizationService.ClearWaveConditionsCalculationOutputAndRemoveTargetProbability <ICalculatableFailureMechanism, ICalculation <WaveConditionsInput> >(
                new TestCalculatableFailureMechanism(), null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("calculationsForTargetProbability", exception.ParamName);
        }
        public void ClearWaveConditionsCalculationOutputAndRemoveTargetProbability_FailureMechanismNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => WaveConditionsDataSynchronizationService.ClearWaveConditionsCalculationOutputAndRemoveTargetProbability <ICalculatableFailureMechanism, ICalculation <WaveConditionsInput> >(
                null, new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1));

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("failureMechanism", exception.ParamName);
        }
        public void ClearWaveConditionsCalculationOutputAndRemoveTargetProbability_WithAllData_ClearsOutputAndRemovesTargetProbabilityAndReturnsAffectedObjects()
        {
            // Setup
            var calculationsForTargetProbabilityToClear = new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1);
            var otherCalculationsForTargetProbability   = new HydraulicBoundaryLocationCalculationsForTargetProbability(0.01);

            var calculation1 = new TestWaveConditionsCalculation <WaveConditionsInput>(new WaveConditionsInput
            {
                WaterLevelType = WaveConditionsInputWaterLevelType.SignalFloodingProbability
            }, true);
            var calculation2 = new TestWaveConditionsCalculation <WaveConditionsInput>(new WaveConditionsInput
            {
                WaterLevelType = WaveConditionsInputWaterLevelType.MaximumAllowableFloodingProbability
            }, true);
            var calculation3 = new TestWaveConditionsCalculation <WaveConditionsInput>(new WaveConditionsInput
            {
                WaterLevelType = WaveConditionsInputWaterLevelType.None
            }, true);
            var calculation4 = new TestWaveConditionsCalculation <WaveConditionsInput>(new WaveConditionsInput
            {
                WaterLevelType = WaveConditionsInputWaterLevelType.UserDefinedTargetProbability,
                CalculationsTargetProbability = calculationsForTargetProbabilityToClear
            }, true);
            var calculation5 = new TestWaveConditionsCalculation <WaveConditionsInput>(new WaveConditionsInput
            {
                WaterLevelType = WaveConditionsInputWaterLevelType.UserDefinedTargetProbability,
                CalculationsTargetProbability = otherCalculationsForTargetProbability
            }, true);

            var mocks            = new MockRepository();
            var failureMechanism = mocks.Stub <ICalculatableFailureMechanism>();

            failureMechanism.Stub(fm => fm.Calculations).Return(new[]
            {
                calculation1,
                calculation2,
                calculation3,
                calculation4,
                calculation5
            });
            mocks.ReplayAll();

            TestWaveConditionsCalculation <WaveConditionsInput>[] expectedAffectedCalculations =
            {
                calculation4
            };

            var expectedAffectedObjects = new IObservable[]
            {
                calculation4,
                calculation4.InputParameters
            };

            // Call
            IEnumerable <IObservable> affectedObjects = WaveConditionsDataSynchronizationService.ClearWaveConditionsCalculationOutputAndRemoveTargetProbability <ICalculatableFailureMechanism, TestWaveConditionsCalculation <WaveConditionsInput> >(
                failureMechanism, calculationsForTargetProbabilityToClear);

            // Assert
            CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
            Assert.IsTrue(expectedAffectedCalculations.All(
                              c => !c.HasOutput &&
                              c.InputParameters.WaterLevelType == WaveConditionsInputWaterLevelType.None));
            Assert.IsTrue(expectedAffectedCalculations.All(c => c.InputParameters.CalculationsTargetProbability == null));

            Assert.IsTrue(failureMechanism.Calculations.Except(expectedAffectedCalculations).All(c => c.HasOutput));
            Assert.IsNotNull(calculation5.InputParameters.CalculationsTargetProbability);
            mocks.VerifyAll();
        }