Esempio n. 1
0
        public void CreateCalculationActivity_WithValidCalculation_ReturnsMacroStabilityInwardsCalculationActivityWithParametersSet()
        {
            // Setup
            var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
            var assessmentSection         = new AssessmentSectionStub
            {
                FailureMechanismContribution =
                {
                    NormativeProbabilityType = NormativeProbabilityType.MaximumAllowableFloodingProbability
                }
            };

            assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
            {
                hydraulicBoundaryLocation
            });

            var random = new Random(39);

            HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation = assessmentSection.WaterLevelCalculationsForMaximumAllowableFloodingProbability.Single();

            hydraulicBoundaryLocationCalculation.Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble());

            MacroStabilityInwardsCalculationScenario calculation = CreateValidCalculation(hydraulicBoundaryLocation);

            // Call
            CalculatableActivity activity = MacroStabilityInwardsCalculationActivityFactory.CreateCalculationActivity(calculation, new GeneralMacroStabilityInwardsInput(), assessmentSection);

            // Assert
            Assert.IsInstanceOf <MacroStabilityInwardsCalculationActivity>(activity);
            AssertMacroStabilityInwardsCalculationActivity(activity, calculation, hydraulicBoundaryLocationCalculation);
        }
        /// <summary>
        /// Creates a collection of <see cref="CalculatableActivity"/> for all relevant calculations
        /// in the given <see cref="AssessmentSection"/>.
        /// </summary>
        /// <param name="assessmentSection">The assessment section to create the activities for.</param>
        /// <returns>A collection of <see cref="CalculatableActivity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="assessmentSection"/> is <c>null</c>.</exception>
        public static IEnumerable <CalculatableActivity> CreateCalculationActivities(AssessmentSection assessmentSection)
        {
            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            var activities = new List <CalculatableActivity>();

            activities.AddRange(PipingCalculationActivityFactory.CreateCalculationActivities(
                                    assessmentSection.Piping,
                                    assessmentSection));
            activities.AddRange(GrassCoverErosionInwardsCalculationActivityFactory.CreateCalculationActivities(
                                    assessmentSection.GrassCoverErosionInwards,
                                    assessmentSection));
            activities.AddRange(MacroStabilityInwardsCalculationActivityFactory.CreateCalculationActivities(
                                    assessmentSection.MacroStabilityInwards,
                                    assessmentSection));
            activities.AddRange(HeightStructuresCalculationActivityFactory.CreateCalculationActivities(
                                    assessmentSection.HeightStructures,
                                    assessmentSection));
            activities.AddRange(ClosingStructuresCalculationActivityFactory.CreateCalculationActivities(
                                    assessmentSection.ClosingStructures,
                                    assessmentSection));
            activities.AddRange(StabilityPointStructuresCalculationActivityFactory.CreateCalculationActivities(
                                    assessmentSection.StabilityPointStructures,
                                    assessmentSection));

            return(activities);
        }
Esempio n. 3
0
        public void CreateCalculationActivitiesForFailureMechanism_AssessmentSectionNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => MacroStabilityInwardsCalculationActivityFactory.CreateCalculationActivities(new MacroStabilityInwardsFailureMechanism(), null);

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

            Assert.AreEqual("assessmentSection", exception.ParamName);
        }
Esempio n. 4
0
        public void CreateCalculationActivitiesForCalculationGroup_AssessmentSectionNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => MacroStabilityInwardsCalculationActivityFactory.CreateCalculationActivities(new CalculationGroup(), new GeneralMacroStabilityInwardsInput(), null);

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

            Assert.AreEqual("assessmentSection", exception.ParamName);
        }
Esempio n. 5
0
        public void CreateCalculationActivitiesForCalculationGroup_WithValidCalculations_ReturnsMacroStabilityInwardsCalculationActivitiesWithParametersSet()
        {
            // Setup
            var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation();
            var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation();

            var assessmentSection = new AssessmentSectionStub
            {
                FailureMechanismContribution =
                {
                    NormativeProbabilityType = NormativeProbabilityType.MaximumAllowableFloodingProbability
                }
            };

            assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
            {
                hydraulicBoundaryLocation1,
                hydraulicBoundaryLocation2
            });

            var random = new Random(39);

            HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation1 = assessmentSection.WaterLevelCalculationsForMaximumAllowableFloodingProbability.First();

            hydraulicBoundaryLocationCalculation1.Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble());

            HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation2 = assessmentSection.WaterLevelCalculationsForMaximumAllowableFloodingProbability.ElementAt(1);

            hydraulicBoundaryLocationCalculation2.Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble());

            MacroStabilityInwardsCalculationScenario calculation1 = CreateValidCalculation(hydraulicBoundaryLocation1);
            MacroStabilityInwardsCalculationScenario calculation2 = CreateValidCalculation(hydraulicBoundaryLocation2);

            var calculations = new CalculationGroup
            {
                Children =
                {
                    calculation1,
                    calculation2
                }
            };

            // Call
            IEnumerable <CalculatableActivity> activities = MacroStabilityInwardsCalculationActivityFactory.CreateCalculationActivities(
                calculations, new GeneralMacroStabilityInwardsInput(), assessmentSection);

            // Assert
            CollectionAssert.AllItemsAreInstancesOfType(activities, typeof(MacroStabilityInwardsCalculationActivity));
            Assert.AreEqual(2, activities.Count());

            AssertMacroStabilityInwardsCalculationActivity(activities.First(), calculation1, hydraulicBoundaryLocationCalculation1);
            AssertMacroStabilityInwardsCalculationActivity(activities.ElementAt(1), calculation2, hydraulicBoundaryLocationCalculation2);
        }
Esempio n. 6
0
        public void CreateCalculationActivity_AssessmentSectionNull_ThrowsArgumentNullException()
        {
            // Setup
            MacroStabilityInwardsCalculationScenario calculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithInvalidInput();

            // Call
            void Call() => MacroStabilityInwardsCalculationActivityFactory.CreateCalculationActivity(calculation, new GeneralMacroStabilityInwardsInput(), null);

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

            Assert.AreEqual("assessmentSection", exception.ParamName);
        }
Esempio n. 7
0
        public void CreateCalculationActivity_CalculationNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            // Call
            void Call() => MacroStabilityInwardsCalculationActivityFactory.CreateCalculationActivity(null, new GeneralMacroStabilityInwardsInput(), assessmentSection);

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

            Assert.AreEqual("calculation", exception.ParamName);
            mocks.VerifyAll();
        }
Esempio n. 8
0
        public void CreateCalculationActivitiesForFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            // Call
            void Call() => MacroStabilityInwardsCalculationActivityFactory.CreateCalculationActivities(null, assessmentSection);

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

            Assert.AreEqual("failureMechanism", exception.ParamName);
            mocks.VerifyAll();
        }
Esempio n. 9
0
        public void CreateCalculationActivity_GeneralInputNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            MacroStabilityInwardsCalculationScenario calculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithInvalidInput();

            // Call
            void Call() => MacroStabilityInwardsCalculationActivityFactory.CreateCalculationActivity(calculation, null, assessmentSection);

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

            Assert.AreEqual("generalInput", exception.ParamName);
            mocks.VerifyAll();
        }