public void ClearAllWaveConditionsCalculationsOutputWithUserDefinedTargetProbability_WithAllData_ClearsOutputAndReturnsAffectedObjects()
        {
            // Setup
            var calculationsForTargetProbabilityToClear = new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1);
            var otherCalculationsForTargetProbability   = new HydraulicBoundaryLocationCalculationsForTargetProbability(0.01);

            var calculation1 = new TestWaveConditionsCalculation <WaveConditionsInput>(new WaveConditionsInput
            {
                WaterLevelType = WaveConditionsInputWaterLevelType.SignalFloodingProbability,
                CalculationsTargetProbability = calculationsForTargetProbabilityToClear
            }, true);
            var calculation2 = new TestWaveConditionsCalculation <WaveConditionsInput>(new WaveConditionsInput
            {
                WaterLevelType = WaveConditionsInputWaterLevelType.MaximumAllowableFloodingProbability,
                CalculationsTargetProbability = calculationsForTargetProbabilityToClear
            }, true);
            var calculation3 = new TestWaveConditionsCalculation <WaveConditionsInput>(new WaveConditionsInput
            {
                WaterLevelType = WaveConditionsInputWaterLevelType.None,
                CalculationsTargetProbability = calculationsForTargetProbabilityToClear
            }, 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
            };

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

            // Assert
            CollectionAssert.AreEqual(expectedAffectedCalculations, affectedCalculations);
            Assert.IsTrue(expectedAffectedCalculations.All(c => !c.HasOutput));
            Assert.IsTrue(failureMechanism.Calculations.Except(expectedAffectedCalculations).All(c => c.HasOutput));
            mocks.VerifyAll();
        }
        public void ClearAllWaveConditionsCalculationOutputWithNormativeProbabilityType_FailureMechanismNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => WaveConditionsDataSynchronizationService.ClearAllWaveConditionsCalculationOutput <ICalculatableFailureMechanism, ICalculation <WaveConditionsInput> >(
                null, NormativeProbabilityType.SignalFloodingProbability);

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

            Assert.AreEqual("failureMechanism", exception.ParamName);
        }
        public void ClearAllWaveConditionsCalculationsOutputWithUserDefinedTargetProbability_CalculationsForTargetProbabilityNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => WaveConditionsDataSynchronizationService.ClearAllWaveConditionsCalculationOutput <ICalculatableFailureMechanism, ICalculation <WaveConditionsInput> >(
                new TestCalculatableFailureMechanism(), null);

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

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

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

            Assert.AreEqual("failureMechanism", exception.ParamName);
        }
        public void ClearAllWaveConditionsCalculationOutputWithNormativeProbabilityType_WithAllData_ClearsOutputAndReturnsAffectedObjects(NormativeProbabilityType normativeProbabilityType)
        {
            // Setup
            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
            }, true);

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

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

            TestWaveConditionsCalculation <WaveConditionsInput>[] expectedAffectedCalculations =
            {
                normativeProbabilityType == NormativeProbabilityType.MaximumAllowableFloodingProbability
                    ? calculation2
                    : calculation1
            };

            // Call
            IEnumerable <IObservable> affectedCalculations = WaveConditionsDataSynchronizationService.ClearAllWaveConditionsCalculationOutput <ICalculatableFailureMechanism, TestWaveConditionsCalculation <WaveConditionsInput> >(
                failureMechanism, normativeProbabilityType);

            // Assert
            CollectionAssert.AreEqual(expectedAffectedCalculations, affectedCalculations);
            Assert.IsTrue(expectedAffectedCalculations.All(c => !c.HasOutput));
            Assert.IsTrue(failureMechanism.Calculations.Except(expectedAffectedCalculations).All(c => c.HasOutput));
            mocks.VerifyAll();
        }
        public void ClearAllWaveConditionsCalculationOutputWithNormativeProbabilityType_InvalidNormativeProbabilityType_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            const NormativeProbabilityType normativeProbabilityType = (NormativeProbabilityType)99;

            // Call
            void Call() => WaveConditionsDataSynchronizationService.ClearAllWaveConditionsCalculationOutput <ICalculatableFailureMechanism, ICalculation <WaveConditionsInput> >(
                new TestCalculatableFailureMechanism(), normativeProbabilityType);

            // Assert
            var expectedMessage = $"The value of argument 'normativeProbabilityType' ({normativeProbabilityType}) is invalid for Enum type '{nameof(NormativeProbabilityType)}'.";
            var exception       = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, expectedMessage);

            Assert.AreEqual("normativeProbabilityType", exception.ParamName);
        }