コード例 #1
0
        public void GetFailureMechanisms_Always_ReturnAllFailureMechanisms(AssessmentSectionComposition composition)
        {
            // Setup
            var assessmentSection = new AssessmentSection(composition);

            // Call
            IFailureMechanism[] failureMechanisms = assessmentSection.GetFailureMechanisms().ToArray();

            // Assert
            Assert.AreEqual(15, failureMechanisms.Length);
            CollectionAssert.AreEqual(new IFailureMechanism[]
            {
                assessmentSection.Piping,
                assessmentSection.GrassCoverErosionInwards,
                assessmentSection.MacroStabilityInwards,
                assessmentSection.Microstability,
                assessmentSection.StabilityStoneCover,
                assessmentSection.WaveImpactAsphaltCover,
                assessmentSection.WaterPressureAsphaltCover,
                assessmentSection.GrassCoverErosionOutwards,
                assessmentSection.GrassCoverSlipOffOutwards,
                assessmentSection.GrassCoverSlipOffInwards,
                assessmentSection.HeightStructures,
                assessmentSection.ClosingStructures,
                assessmentSection.PipingStructure,
                assessmentSection.StabilityPointStructures,
                assessmentSection.DuneErosion
            }, failureMechanisms);
        }
コード例 #2
0
        public void AssembleAssessmentSection_AssessmentSectionContainingFailureMechanismsWithRandomInAssemblyState_SetsInputOnCalculator()
        {
            // Setup
            AssessmentSection assessmentSection = CreateAssessmentSectionContainingFailureMechanismsWithRandomInAssemblyState();

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                FailureMechanismAssemblyCalculatorStub  failureMechanismAssemblyCalculator  = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator;
                AssessmentSectionAssemblyCalculatorStub assessmentSectionAssemblyCalculator = calculatorFactory.LastCreatedAssessmentSectionAssemblyCalculator;

                // Call
                AssessmentSectionAssemblyFactory.AssembleAssessmentSection(assessmentSection);

                // Assert
                FailureMechanismContribution contribution = assessmentSection.FailureMechanismContribution;
                Assert.AreEqual(contribution.SignalFloodingProbability, assessmentSectionAssemblyCalculator.SignalFloodingProbability);
                Assert.AreEqual(contribution.MaximumAllowableFloodingProbability, assessmentSectionAssemblyCalculator.MaximumAllowableFloodingProbabilityInput);

                int expectedNrOfProbabilities = assessmentSection.GetFailureMechanisms()
                                                .Concat(assessmentSection.SpecificFailureMechanisms)
                                                .Count(fp => fp.InAssembly);
                IEnumerable <double> calculatorInput = assessmentSectionAssemblyCalculator.FailureMechanismProbabilitiesInput;
                Assert.AreEqual(expectedNrOfProbabilities, calculatorInput.Count());
                foreach (double failureMechanismProbability in calculatorInput)
                {
                    Assert.AreEqual(failureMechanismAssemblyCalculator.AssemblyResultOutput.AssemblyResult, failureMechanismProbability);
                }
            }
        }
コード例 #3
0
        public void GetMergeData_WithAssessmentSection_SetsDataOnDialog()
        {
            // Setup
            DialogBoxHandler = (formName, wnd) =>
            {
                using (new FormTester(formName)) {}
            };

            AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurationsAndSpecificFailureMechanisms();

            using (var dialogParent = new Form())
                using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent))
                {
                    // Call
                    dialog.GetMergeData(assessmentSection);

                    // Assert
                    var dataGridView = (DataGridView) new ControlTester("dataGridView", dialog).TheObject;
                    DataGridViewRowCollection rows = dataGridView.Rows;

                    int expectedNrOfRows = assessmentSection.GetFailureMechanisms().Count() +
                                           assessmentSection.SpecificFailureMechanisms.Count;
                    Assert.AreEqual(expectedNrOfRows, rows.Count);
                    AssertFailureMechanismRows(assessmentSection, rows);
                    AssertSpecificFailureMechanismRows(assessmentSection, rows);
                }
        }
コード例 #4
0
        public void GivenFormWithAssemblyResultPerSectionView_WhenFailureMechanismNotifiesObservers_ThenRefreshButtonEnabledAndWarningSet()
        {
            // Given
            var random = new Random(21);
            AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllFailureMechanismSectionsAndResults(
                random.NextEnumValue <AssessmentSectionComposition>());

            using (new AssemblyToolCalculatorFactoryConfig())
                using (AssemblyResultPerSectionView view = ShowAssemblyResultPerSectionView(assessmentSection))
                {
                    // Precondition
                    ButtonTester buttonTester = GetRefreshAssemblyResultButtonTester();
                    Button       button       = buttonTester.Properties;
                    Assert.IsFalse(button.Enabled);
                    ErrorProvider warningProvider = GetWarningProvider(view);
                    Assert.IsEmpty(warningProvider.GetError(button));

                    // When
                    IFailureMechanism[] failureMechanisms = assessmentSection.GetFailureMechanisms().ToArray();
                    failureMechanisms[random.Next(failureMechanisms.Length)].NotifyObservers();

                    // Then
                    Assert.IsTrue(buttonTester.Properties.Enabled);
                    Assert.AreEqual(assemblyResultOutdatedWarning, warningProvider.GetError(button));
                }
        }
        public void CreateInput_WithAllFailureMechanisms_ReturnsInputCollection()
        {
            // Setup
            var random = new Random(21);
            AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllFailureMechanismSectionsAndResults(
                random.NextEnumValue <AssessmentSectionComposition>());

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;

                // Call
                IEnumerable <IEnumerable <CombinedAssemblyFailureMechanismSection> > inputs = CombinedAssemblyFailureMechanismSectionFactory.CreateInput(
                    assessmentSection, assessmentSection.GetFailureMechanisms().Concat(assessmentSection.SpecificFailureMechanisms));

                // Assert
                int expectedNrOfGeneralSectionResults  = assessmentSection.GetFailureMechanisms().Count();
                int expectedNrOfSpecificSectionResults = assessmentSection.SpecificFailureMechanisms.Count;
                Assert.AreEqual(expectedNrOfGeneralSectionResults + expectedNrOfSpecificSectionResults, inputs.Count());

                FailureMechanismSectionAssemblyResult assemblyResult = calculator.FailureMechanismSectionAssemblyResultOutput.AssemblyResult;
                AssertSectionsWithResult(assessmentSection.Piping.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(0));
                AssertSectionsWithResult(assessmentSection.GrassCoverErosionInwards.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(1));
                AssertSectionsWithResult(assessmentSection.MacroStabilityInwards.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(2));
                AssertSectionsWithResult(assessmentSection.Microstability.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(3));
                AssertSectionsWithResult(assessmentSection.StabilityStoneCover.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(4));
                AssertSectionsWithResult(assessmentSection.WaveImpactAsphaltCover.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(5));
                AssertSectionsWithResult(assessmentSection.WaterPressureAsphaltCover.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(6));
                AssertSectionsWithResult(assessmentSection.GrassCoverErosionOutwards.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(7));
                AssertSectionsWithResult(assessmentSection.GrassCoverSlipOffOutwards.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(8));
                AssertSectionsWithResult(assessmentSection.GrassCoverSlipOffInwards.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(9));
                AssertSectionsWithResult(assessmentSection.HeightStructures.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(10));
                AssertSectionsWithResult(assessmentSection.ClosingStructures.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(11));
                AssertSectionsWithResult(assessmentSection.PipingStructure.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(12));
                AssertSectionsWithResult(assessmentSection.StabilityPointStructures.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(13));
                AssertSectionsWithResult(assessmentSection.DuneErosion.SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup, inputs.ElementAt(14));
                for (var i = 0; i < expectedNrOfSpecificSectionResults; i++)
                {
                    AssertSectionsWithResult(assessmentSection.SpecificFailureMechanisms[i].SectionResults, assemblyResult.FailureMechanismSectionAssemblyGroup,
                                             inputs.ElementAt(expectedNrOfGeneralSectionResults + i));
                }
            }
        }
コード例 #6
0
        private static void AssertSpecificFailureMechanismRows(AssessmentSection expectedAssessmentSection, DataGridViewRowCollection rows)
        {
            int offset = expectedAssessmentSection.GetFailureMechanisms().Count();
            ObservableList <SpecificFailureMechanism> failureMechanisms = expectedAssessmentSection.SpecificFailureMechanisms;

            for (int i = 0; i < failureMechanisms.Count; i++)
            {
                AssertDataGridViewRow(failureMechanisms[i], rows[i + offset].Cells);
            }
        }
コード例 #7
0
        private static AssessmentSection CreateAssessmentSectionContainingFailureMechanismsWithRandomInAssemblyState()
        {
            var random = new Random(21);

            AssessmentSection assessmentSection = CreateAssessmentSectionContainingFailureMechanismsWithInAssemblyTrue();

            assessmentSection.GetFailureMechanisms()
            .Concat(assessmentSection.SpecificFailureMechanisms)
            .ForEachElementDo(fp => fp.InAssembly = random.NextBoolean());

            return(assessmentSection);
        }
コード例 #8
0
        public void GivenViewWithAssemblyResults_WhenFailureMechanismNotifiesObserver_ThenAssemblyResultsRefreshed()
        {
            // Given
            var random = new Random(21);
            AssessmentSection assessmentSection = CreateAssessmentSectionWithReferenceLine();

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                AssessmentSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedAssessmentSectionAssemblyCalculator;
                calculator.CombinedFailureMechanismSectionAssemblyOutput = new CombinedFailureMechanismSectionAssemblyResultWrapper(
                    new[]
                {
                    CombinedFailureMechanismSectionAssemblyTestFactory.Create(assessmentSection, 10)
                }, AssemblyMethod.BOI3A1, AssemblyMethod.BOI3B1, AssemblyMethod.BOI3C1);

                using (var view = new AssemblyResultPerSectionMapView(assessmentSection))
                {
                    // Precondition
                    MapDataCollection mapData = view.Map.Data;

                    var         mocks     = new MockRepository();
                    IObserver[] observers = AttachMapDataObservers(mocks, mapData.Collection);
                    observers[referenceLineIndex].Expect(obs => obs.UpdateObserver());
                    observers[assemblyResultsObserverIndex].Expect(obs => obs.UpdateObserver());
                    mocks.ReplayAll();

                    IEnumerable <CombinedFailureMechanismSectionAssemblyResult> expectedResults =
                        AssessmentSectionAssemblyFactory.AssembleCombinedPerFailureMechanismSection(assessmentSection);

                    AssertCombinedFailureMechanismSectionAssemblyResultMapData(expectedResults,
                                                                               assessmentSection.ReferenceLine,
                                                                               mapData.Collection.ElementAt(assemblyResultsIndex));

                    // When
                    calculator.CombinedFailureMechanismSectionAssemblyOutput = new CombinedFailureMechanismSectionAssemblyResultWrapper(
                        new[]
                    {
                        CombinedFailureMechanismSectionAssemblyTestFactory.Create(assessmentSection, 20)
                    }, AssemblyMethod.BOI3A1, AssemblyMethod.BOI3B1, AssemblyMethod.BOI3C1);
                    IEnumerable <IFailureMechanism> failureMechanisms = assessmentSection.GetFailureMechanisms();
                    failureMechanisms.ElementAt(random.Next(failureMechanisms.Count())).NotifyObservers();

                    // Then
                    expectedResults = AssessmentSectionAssemblyFactory.AssembleCombinedPerFailureMechanismSection(assessmentSection);
                    AssertCombinedFailureMechanismSectionAssemblyResultMapData(expectedResults,
                                                                               assessmentSection.ReferenceLine,
                                                                               mapData.Collection.ElementAt(assemblyResultsIndex));
                    mocks.VerifyAll();
                }
            }
        }
        public void CreateInput_WithOneFailureMechanism_ReturnsInputCollection(AssessmentSection assessmentSection, IFailureMechanism failureMechanismInAssembly)
        {
            // Setup
            assessmentSection.GetFailureMechanisms()
            .ForEachElementDo(failureMechanism => failureMechanism.InAssembly = failureMechanism == failureMechanismInAssembly);

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                // Call
                IEnumerable <IEnumerable <CombinedAssemblyFailureMechanismSection> > inputs = CombinedAssemblyFailureMechanismSectionFactory.CreateInput(
                    assessmentSection, new[]
                {
                    failureMechanismInAssembly
                });

                // Assert
                IObservableEnumerable <FailureMechanismSectionResult> failureMechanismSectionResults = ((IFailureMechanism <FailureMechanismSectionResult>)failureMechanismInAssembly).SectionResults;
                AssertSections(failureMechanismSectionResults, inputs.Single());
            }
        }
        public void Update_LocationsWithOutput_ClearOutputAndReturnChangedObjects()
        {
            // Setup
            AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations();
            var handler = new HydraulicLocationConfigurationDatabaseUpdateHandler(assessmentSection);

            IEnumerable <HydraulicBoundaryLocationCalculation> locations = GetLocationCalculations(assessmentSection);
            IEnumerable <DuneLocationCalculation> duneLocations          = GetDuneLocationCalculations(assessmentSection);

            ICalculation[] calculationsWithOutput = assessmentSection.GetFailureMechanisms()
                                                    .OfType <ICalculatableFailureMechanism>()
                                                    .SelectMany(fm => fm.Calculations)
                                                    .Where(c => c.HasOutput)
                                                    .ToArray();

            calculationsWithOutput = calculationsWithOutput.Except(calculationsWithOutput.OfType <SemiProbabilisticPipingCalculationScenario>()
                                                                   .Where(c => c.InputParameters.UseAssessmentLevelManualInput))
                                     .Except(calculationsWithOutput.OfType <MacroStabilityInwardsCalculationScenario>()
                                             .Where(c => c.InputParameters.UseAssessmentLevelManualInput))
                                     .Except(calculationsWithOutput.OfType <TestPipingCalculationScenario>())
                                     .ToArray();

            // Precondition
            Assert.IsTrue(locations.All(l => l.HasOutput));
            Assert.IsTrue(duneLocations.All(l => l.Output != null));

            // Call
            IEnumerable <IObservable> changedObjects = handler.Update(assessmentSection.HydraulicBoundaryDatabase, null, false, "some/file/path");

            // Assert
            Assert.IsTrue(locations.All(l => !l.HasOutput));
            Assert.IsTrue(duneLocations.All(l => l.Output == null));
            Assert.IsTrue(calculationsWithOutput.All(c => !c.HasOutput));

            IEnumerable <IObservable> expectedChangedObjects = new IObservable[]
            {
                assessmentSection.HydraulicBoundaryDatabase
            }.Concat(locations).Concat(duneLocations).Concat(calculationsWithOutput);

            CollectionAssert.AreEquivalent(expectedChangedObjects, changedObjects);
        }
コード例 #11
0
        public void ChangeComposition_ChangeToSameValue_DoNothing()
        {
            // Setup
            var mocks        = new MockRepository();
            var viewCommands = mocks.StrictMock <IViewCommands>();

            mocks.ReplayAll();

            AssessmentSection            assessmentSection   = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations();
            AssessmentSectionComposition originalComposition = assessmentSection.Composition;

            ICalculation[] calculationsWithOutput = assessmentSection.GetFailureMechanisms()
                                                    .OfType <ICalculatableFailureMechanism>()
                                                    .SelectMany(fm => fm.Calculations)
                                                    .Where(c => c.HasOutput)
                                                    .ToArray();

            IEnumerable <DuneLocationCalculation> duneLocationCalculationsWithOutput = assessmentSection.DuneErosion.DuneLocationCalculationsForUserDefinedTargetProbabilities.SelectMany(tp => tp.DuneLocationCalculations)
                                                                                       .Where(HasDuneLocationCalculationOutput)
                                                                                       .ToArray();

            IEnumerable <HydraulicBoundaryLocationCalculation> hydraulicBoundaryLocationCalculationsWithOutput = assessmentSection.WaterLevelCalculationsForMaximumAllowableFloodingProbability.Where(HasHydraulicBoundaryLocationCalculationOutput)
                                                                                                                 .Concat(assessmentSection.WaterLevelCalculationsForSignalFloodingProbability.Where(HasHydraulicBoundaryLocationCalculationOutput))
                                                                                                                 .Concat(assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities.SelectMany(tp => tp.HydraulicBoundaryLocationCalculations))
                                                                                                                 .ToArray();

            var handler = new AssessmentSectionCompositionChangeHandler(viewCommands);

            // Call
            IEnumerable <IObservable> affectedObjects = handler.ChangeComposition(assessmentSection, originalComposition);

            // Assert
            Assert.True(calculationsWithOutput.All(c => c.HasOutput),
                        "All calculations that had output still have them.");

            Assert.True(duneLocationCalculationsWithOutput.All(HasDuneLocationCalculationOutput));
            Assert.True(hydraulicBoundaryLocationCalculationsWithOutput.All(calc => calc.HasOutput));

            CollectionAssert.IsEmpty(affectedObjects);
            mocks.VerifyAll();
        }
コード例 #12
0
        /// <summary>
        /// Assembles the combined failure mechanism sections.
        /// </summary>
        /// <param name="assessmentSection">The assessment section that contains all
        /// the failure mechanism sections to assemble.</param>
        /// <returns>A collection of <see cref="CombinedFailureMechanismSectionAssemblyResult"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="assessmentSection"/>
        /// is <c>null</c>.</exception>
        /// <exception cref="AssemblyException">Thrown when a <see cref="CombinedFailureMechanismSectionAssemblyResult"/>
        /// cannot be created.</exception>
        public static IEnumerable <CombinedFailureMechanismSectionAssemblyResult> AssembleCombinedPerFailureMechanismSection(
            AssessmentSection assessmentSection)
        {
            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            try
            {
                IAssemblyToolCalculatorFactory       calculatorFactory = AssemblyToolCalculatorFactory.Instance;
                IAssessmentSectionAssemblyCalculator calculator        = calculatorFactory.CreateAssessmentSectionAssemblyCalculator(
                    AssemblyToolKernelFactory.Instance);

                Dictionary <IFailureMechanism, int> failureMechanismsToAssemble = assessmentSection.GetFailureMechanisms()
                                                                                  .Concat(assessmentSection.SpecificFailureMechanisms)
                                                                                  .Where(fm => fm.InAssembly)
                                                                                  .Select((fm, i) => new
                {
                    FailureMechanism = fm,
                    Index            = i
                })
                                                                                  .ToDictionary(x => x.FailureMechanism, x => x.Index);

                CombinedFailureMechanismSectionAssemblyResultWrapper output = calculator.AssembleCombinedFailureMechanismSections(
                    CombinedAssemblyFailureMechanismSectionFactory.CreateInput(assessmentSection, failureMechanismsToAssemble.Keys),
                    assessmentSection.ReferenceLine.Length);

                return(CombinedFailureMechanismSectionAssemblyResultFactory.Create(output, failureMechanismsToAssemble, assessmentSection));
            }
            catch (AssessmentSectionAssemblyCalculatorException e)
            {
                throw new AssemblyException(e.Message, e);
            }
            catch (AssemblyException e)
            {
                throw new AssemblyException(Resources.AssessmentSectionAssemblyFactory_Error_while_assembling_failureMechanisms, e);
            }
        }
コード例 #13
0
        public void AssembleCombinedPerFailureMechanismSection_WithAssessmentSection_SetsInputOnCalculator(bool failureMechanismSectionAssemblyThrowsException)
        {
            var random = new Random(21);
            AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllFailureMechanismSectionsAndResults(
                random.NextEnumValue <AssessmentSectionComposition>());

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                FailureMechanismSectionAssemblyCalculatorStub failureMechanismSectionAssemblyCalculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
                failureMechanismSectionAssemblyCalculator.ThrowExceptionOnCalculate = failureMechanismSectionAssemblyThrowsException;

                // Call
                AssessmentSectionAssemblyFactory.AssembleCombinedPerFailureMechanismSection(assessmentSection);

                // Assert
                AssessmentSectionAssemblyCalculatorStub assessmentSectionAssemblyCalculator = calculatorFactory.LastCreatedAssessmentSectionAssemblyCalculator;
                IEnumerable <CombinedAssemblyFailureMechanismSection>[] actualInput         = assessmentSectionAssemblyCalculator.CombinedFailureMechanismSectionsInput.ToArray();
                IEnumerable <CombinedAssemblyFailureMechanismSection>[] expectedInput       = CombinedAssemblyFailureMechanismSectionFactory.CreateInput(
                    assessmentSection, assessmentSection.GetFailureMechanisms().Concat(assessmentSection.SpecificFailureMechanisms)).ToArray();
                Assert.AreEqual(expectedInput.Length, actualInput.Length);

                for (var i = 0; i < expectedInput.Length; i++)
                {
                    CombinedAssemblyFailureMechanismSection[] actualSections   = actualInput[i].ToArray();
                    CombinedAssemblyFailureMechanismSection[] expectedSections = expectedInput[i].ToArray();
                    Assert.AreEqual(expectedSections.Length, actualSections.Length);

                    for (var j = 0; j < expectedSections.Length; j++)
                    {
                        Assert.AreEqual(expectedSections[j].SectionStart, actualSections[j].SectionStart);
                        Assert.AreEqual(expectedSections[j].SectionEnd, actualSections[j].SectionEnd);
                        Assert.AreEqual(expectedSections[j].FailureMechanismSectionAssemblyGroup, actualSections[j].FailureMechanismSectionAssemblyGroup);
                    }
                }
            }
        }
コード例 #14
0
        public void GivenFormWithAssemblyResultTotalView_WhenFailureMechanismNotifiesObservers_ThenRefreshButtonEnabledAndWarningSet()
        {
            // Given
            var random = new Random(21);
            AssessmentSection assessmentSection = CreateAssessmentSection();

            using (AssemblyResultTotalView view = ShowAssemblyResultTotalView(assessmentSection))
            {
                // Precondition
                ButtonTester buttonTester = GetRefreshAssemblyResultButtonTester();
                Button       button       = buttonTester.Properties;
                Assert.IsFalse(button.Enabled);
                ErrorProvider warningProvider = GetWarningProvider(view);
                Assert.IsEmpty(warningProvider.GetError(button));

                // When
                IEnumerable <IFailureMechanism> failureMechanisms = assessmentSection.GetFailureMechanisms();
                failureMechanisms.ElementAt(random.Next(failureMechanisms.Count())).NotifyObservers();

                // Then
                Assert.IsTrue(buttonTester.Properties.Enabled);
                Assert.AreEqual(assemblyResultOutdatedWarning, warningProvider.GetError(button));
            }
        }
コード例 #15
0
        public void Create_WithAllFailureMechanisms_ReturnsCombinedFailureMechanismSectionAssemblyResults()
        {
            // Setup
            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>());

            assessmentSection.SpecificFailureMechanisms.Add(new SpecificFailureMechanism());
            Dictionary <IFailureMechanism, int> failureMechanisms = assessmentSection.GetFailureMechanisms()
                                                                    .Concat(assessmentSection.SpecificFailureMechanisms)
                                                                    .Where(fm => fm.InAssembly)
                                                                    .Select((fm, i) => new
            {
                FailureMechanism = fm,
                Index            = i
            })
                                                                    .ToDictionary(x => x.FailureMechanism, x => x.Index);

            var section1 = new CombinedAssemblyFailureMechanismSection(0, 5, random.NextEnumValue <FailureMechanismSectionAssemblyGroup>());
            var section2 = new CombinedAssemblyFailureMechanismSection(5, 11, random.NextEnumValue <FailureMechanismSectionAssemblyGroup>());
            var output   = new CombinedFailureMechanismSectionAssemblyResultWrapper(
                new[]
            {
                new CombinedFailureMechanismSectionAssembly(section1, GetFailureMechanismsOutput(failureMechanisms.Keys, random)),
                new CombinedFailureMechanismSectionAssembly(section2, GetFailureMechanismsOutput(failureMechanisms.Keys, random))
            }, AssemblyMethod.BOI3A1, AssemblyMethod.BOI3B1, AssemblyMethod.BOI3C1);

            // Call
            CombinedFailureMechanismSectionAssemblyResult[] results = CombinedFailureMechanismSectionAssemblyResultFactory.Create(output, failureMechanisms, assessmentSection).ToArray();

            // Assert
            Assert.AreEqual(output.AssemblyResults.Count(), results.Length);
            for (var i = 0; i < output.AssemblyResults.Count(); i++)
            {
                CombinedFailureMechanismSectionAssembly assemblyResult = output.AssemblyResults.ElementAt(i);
                Assert.AreEqual(assemblyResult.Section.SectionStart, results[i].SectionStart);
                Assert.AreEqual(assemblyResult.Section.SectionEnd, results[i].SectionEnd);
                Assert.AreEqual(assemblyResult.Section.FailureMechanismSectionAssemblyGroup, results[i].TotalResult);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.Piping]), results[i].Piping);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.GrassCoverErosionInwards]), results[i].GrassCoverErosionInwards);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.MacroStabilityInwards]), results[i].MacroStabilityInwards);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.Microstability]), results[i].Microstability);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.StabilityStoneCover]), results[i].StabilityStoneCover);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.WaveImpactAsphaltCover]), results[i].WaveImpactAsphaltCover);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.WaterPressureAsphaltCover]), results[i].WaterPressureAsphaltCover);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.GrassCoverErosionOutwards]), results[i].GrassCoverErosionOutwards);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.GrassCoverSlipOffOutwards]), results[i].GrassCoverSlipOffOutwards);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.GrassCoverSlipOffInwards]), results[i].GrassCoverSlipOffInwards);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.HeightStructures]), results[i].HeightStructures);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.ClosingStructures]), results[i].ClosingStructures);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.PipingStructure]), results[i].PipingStructure);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.StabilityPointStructures]), results[i].StabilityPointStructures);
                Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[assessmentSection.DuneErosion]), results[i].DuneErosion);
                Assert.AreEqual(assessmentSection.SpecificFailureMechanisms.Count, results[i].SpecificFailureMechanisms.Length);
                foreach (SpecificFailureMechanism specificFailureMechanism in assessmentSection.SpecificFailureMechanisms)
                {
                    Assert.AreEqual(assemblyResult.FailureMechanismSectionAssemblyGroupResults.ElementAt(failureMechanisms[specificFailureMechanism]), results[i].SpecificFailureMechanisms.Single());
                }

                Assert.AreEqual(output.CommonSectionAssemblyMethod, results[i].CommonSectionAssemblyMethod);
                Assert.AreEqual(output.FailureMechanismResultsAssemblyMethod, results[i].FailureMechanismResultsAssemblyMethod);
                Assert.AreEqual(output.CombinedSectionResultAssemblyMethod, results[i].CombinedSectionResultAssemblyMethod);
            }
        }
コード例 #16
0
        public void CreateExportableAssessmentSection_AllFailureMechanismNotInAssembly_ReturnsExpectedValues()
        {
            // Setup
            const string name = "assessmentSectionName";
            const string id   = "assessmentSectionId";

            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>())
            {
                Name = name,
                Id   = id
            };

            ReferenceLineTestFactory.SetReferenceLineGeometry(assessmentSection.ReferenceLine);

            assessmentSection.SpecificFailureMechanisms.Add(new SpecificFailureMechanism());
            assessmentSection.SpecificFailureMechanisms.Add(new SpecificFailureMechanism());

            FailureMechanismTestHelper.AddSections(assessmentSection.Piping, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.MacroStabilityInwards, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.GrassCoverErosionInwards, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.HeightStructures, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.ClosingStructures, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.StabilityPointStructures, random.Next(1, 10));

            FailureMechanismTestHelper.AddSections(assessmentSection.StabilityStoneCover, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.WaveImpactAsphaltCover, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.GrassCoverErosionOutwards, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.DuneErosion, random.Next(1, 10));

            FailureMechanismTestHelper.AddSections(assessmentSection.Microstability, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.GrassCoverSlipOffOutwards, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.GrassCoverSlipOffInwards, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.PipingStructure, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.WaterPressureAsphaltCover, random.Next(1, 10));

            FailureMechanismTestHelper.AddSections(assessmentSection.SpecificFailureMechanisms.First(), random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.SpecificFailureMechanisms.Last(), random.Next(1, 10));

            foreach (IFailureMechanism failureMechanism in assessmentSection.GetFailureMechanisms()
                     .Concat(assessmentSection.SpecificFailureMechanisms))
            {
                failureMechanism.InAssembly = false;
            }

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                // Call
                ExportableAssessmentSection exportableAssessmentSection = ExportableAssessmentSectionFactory.CreateExportableAssessmentSection(assessmentSection);

                // Assert
                Assert.AreEqual(name, exportableAssessmentSection.Name);
                Assert.AreEqual(id, exportableAssessmentSection.Id);
                CollectionAssert.AreEqual(assessmentSection.ReferenceLine.Points, exportableAssessmentSection.Geometry);

                ExportableAssessmentSectionAssemblyResult exportableAssessmentSectionAssemblyResult = exportableAssessmentSection.AssessmentSectionAssembly;
                Assert.AreEqual(ExportableAssemblyMethod.BOI2A1, exportableAssessmentSectionAssemblyResult.ProbabilityAssemblyMethod);
                Assert.AreEqual(ExportableAssemblyMethod.BOI2B1, exportableAssessmentSectionAssemblyResult.AssemblyGroupAssemblyMethod);
                Assert.AreEqual(AssessmentSectionAssemblyGroup.APlus, exportableAssessmentSectionAssemblyResult.AssemblyGroup);
                Assert.AreEqual(0.14, exportableAssessmentSectionAssemblyResult.Probability);

                CollectionAssert.IsEmpty(exportableAssessmentSection.FailureMechanisms);

                Assert.AreEqual(1, exportableAssessmentSection.CombinedSectionAssemblies.Count());
                ExportableCombinedSectionAssembly exportableCombinedSectionAssembly = exportableAssessmentSection.CombinedSectionAssemblies.ElementAt(0);
                Assert.AreEqual(FailureMechanismSectionAssemblyGroup.Zero, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.AssemblyGroup);
                Assert.AreEqual(ExportableAssemblyMethod.BOI3C1, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.AssemblyGroupAssemblyMethod);
                Assert.AreEqual(0.0, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.FailureMechanismSection.StartDistance);
                Assert.AreEqual(1.0, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.FailureMechanismSection.EndDistance);
                CollectionAssert.IsEmpty(exportableCombinedSectionAssembly.FailureMechanismResults);
                Assert.AreEqual(ExportableAssemblyMethod.BOI3A1, exportableCombinedSectionAssembly.Section.AssemblyMethod);
                Assert.AreEqual(0.0, exportableCombinedSectionAssembly.Section.StartDistance);
                Assert.AreEqual(1.0, exportableCombinedSectionAssembly.Section.EndDistance);
            }
        }
コード例 #17
0
        public void ChangeComposition_SetNewValue_ChangesCompositionAndReturnAffectedObjects(AssessmentSectionComposition oldComposition,
                                                                                             AssessmentSectionComposition newComposition)
        {
            // Setup
            var mocks        = new MockRepository();
            var viewCommands = mocks.Stub <IViewCommands>();

            mocks.ReplayAll();

            var assessmentSection = new AssessmentSection(oldComposition);

            var handler = new AssessmentSectionCompositionChangeHandler(viewCommands);

            // Call
            IEnumerable <IObservable> affectedObjects = handler.ChangeComposition(assessmentSection, newComposition);

            // Assert
            IEnumerable <IObservable> expectedAffectedObjects = new List <IObservable>(assessmentSection.GetFailureMechanisms())
            {
                assessmentSection,
                assessmentSection.FailureMechanismContribution
            };

            CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
            mocks.VerifyAll();
        }
コード例 #18
0
        private static void AssertFailureMechanismRows(AssessmentSection assessmentSection,
                                                       double assemblyOutput,
                                                       DataGridViewRowCollection rows)
        {
            int nrOfExpectedRows = assessmentSection.GetFailureMechanisms().Count() +
                                   assessmentSection.SpecificFailureMechanisms.Count;

            Assert.AreEqual(nrOfExpectedRows, rows.Count);

            PipingFailureMechanism piping = assessmentSection.Piping;

            AssertAssemblyCells(piping, assemblyOutput, rows[0].Cells);

            GrassCoverErosionInwardsFailureMechanism grassCoverErosionInwards = assessmentSection.GrassCoverErosionInwards;

            AssertAssemblyCells(grassCoverErosionInwards, assemblyOutput, rows[1].Cells);

            MacroStabilityInwardsFailureMechanism macroStabilityInwards = assessmentSection.MacroStabilityInwards;

            AssertAssemblyCells(macroStabilityInwards, assemblyOutput, rows[2].Cells);

            MicrostabilityFailureMechanism microStability = assessmentSection.Microstability;

            AssertAssemblyCells(microStability, assemblyOutput, rows[3].Cells);

            StabilityStoneCoverFailureMechanism stabilityStoneCover = assessmentSection.StabilityStoneCover;

            AssertAssemblyCells(stabilityStoneCover, assemblyOutput, rows[4].Cells);

            WaveImpactAsphaltCoverFailureMechanism waveImpactAsphaltCover = assessmentSection.WaveImpactAsphaltCover;

            AssertAssemblyCells(waveImpactAsphaltCover, assemblyOutput, rows[5].Cells);

            WaterPressureAsphaltCoverFailureMechanism waterPressureAsphaltCover = assessmentSection.WaterPressureAsphaltCover;

            AssertAssemblyCells(waterPressureAsphaltCover, assemblyOutput, rows[6].Cells);

            GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwards = assessmentSection.GrassCoverErosionOutwards;

            AssertAssemblyCells(grassCoverErosionOutwards, assemblyOutput, rows[7].Cells);

            GrassCoverSlipOffOutwardsFailureMechanism grassCoverSlipOffOutwards = assessmentSection.GrassCoverSlipOffOutwards;

            AssertAssemblyCells(grassCoverSlipOffOutwards, assemblyOutput, rows[8].Cells);

            GrassCoverSlipOffInwardsFailureMechanism grassCoverSlipOffInwards = assessmentSection.GrassCoverSlipOffInwards;

            AssertAssemblyCells(grassCoverSlipOffInwards, assemblyOutput, rows[9].Cells);

            HeightStructuresFailureMechanism heightStructures = assessmentSection.HeightStructures;

            AssertAssemblyCells(heightStructures, assemblyOutput, rows[10].Cells);

            ClosingStructuresFailureMechanism closingStructures = assessmentSection.ClosingStructures;

            AssertAssemblyCells(closingStructures, assemblyOutput, rows[11].Cells);

            PipingStructureFailureMechanism pipingStructure = assessmentSection.PipingStructure;

            AssertAssemblyCells(pipingStructure, assemblyOutput, rows[12].Cells);

            StabilityPointStructuresFailureMechanism stabilityPointStructures = assessmentSection.StabilityPointStructures;

            AssertAssemblyCells(stabilityPointStructures, assemblyOutput, rows[13].Cells);

            DuneErosionFailureMechanism duneErosion = assessmentSection.DuneErosion;

            AssertAssemblyCells(duneErosion, assemblyOutput, rows[14].Cells);

            int startIndexFailureMechanismRow = 15;

            for (int i = startIndexFailureMechanismRow; i < nrOfExpectedRows; i++)
            {
                SpecificFailureMechanism specificFailureMechanism = assessmentSection.SpecificFailureMechanisms[i - startIndexFailureMechanismRow];
                AssertAssemblyCells(specificFailureMechanism, assemblyOutput, rows[i].Cells);
            }
        }
コード例 #19
0
        public void AssembleCombinedPerFailureMechanismSection_AssemblyRan_ReturnsOutput()
        {
            var random = new Random(21);
            AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllFailureMechanismSectionsAndResults(
                random.NextEnumValue <AssessmentSectionComposition>());

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                AssessmentSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedAssessmentSectionAssemblyCalculator;
                calculator.CombinedFailureMechanismSectionAssemblyOutput = new CombinedFailureMechanismSectionAssemblyResultWrapper(
                    new[]
                {
                    CombinedFailureMechanismSectionAssemblyTestFactory.Create(assessmentSection, 20),
                    CombinedFailureMechanismSectionAssemblyTestFactory.Create(assessmentSection, 21)
                }, AssemblyMethod.BOI3A1, AssemblyMethod.BOI3B1, AssemblyMethod.BOI3C1);

                // Call
                CombinedFailureMechanismSectionAssemblyResult[] output = AssessmentSectionAssemblyFactory.AssembleCombinedPerFailureMechanismSection(
                    assessmentSection)
                                                                         .ToArray();

                // Assert
                Dictionary <IFailureMechanism, int> failureMechanisms = assessmentSection.GetFailureMechanisms()
                                                                        .Concat(assessmentSection.SpecificFailureMechanisms)
                                                                        .Where(fm => fm.InAssembly)
                                                                        .Select((fm, i) => new
                {
                    FailureMechanism = fm,
                    Index            = i
                })
                                                                        .ToDictionary(x => x.FailureMechanism, x => x.Index);
                CombinedFailureMechanismSectionAssemblyResult[] expectedOutput = CombinedFailureMechanismSectionAssemblyResultFactory.Create(
                    calculator.CombinedFailureMechanismSectionAssemblyOutput, failureMechanisms, assessmentSection).ToArray();

                Assert.AreEqual(expectedOutput.Length, output.Length);
                for (var i = 0; i < expectedOutput.Length; i++)
                {
                    Assert.AreEqual(expectedOutput[i].SectionStart, output[i].SectionStart);
                    Assert.AreEqual(expectedOutput[i].SectionEnd, output[i].SectionEnd);
                    Assert.AreEqual(expectedOutput[i].TotalResult, output[i].TotalResult);
                    Assert.AreEqual(expectedOutput[i].Piping, output[i].Piping);
                    Assert.AreEqual(expectedOutput[i].GrassCoverErosionInwards, output[i].GrassCoverErosionInwards);
                    Assert.AreEqual(expectedOutput[i].MacroStabilityInwards, output[i].MacroStabilityInwards);
                    Assert.AreEqual(expectedOutput[i].Microstability, output[i].Microstability);
                    Assert.AreEqual(expectedOutput[i].StabilityStoneCover, output[i].StabilityStoneCover);
                    Assert.AreEqual(expectedOutput[i].WaveImpactAsphaltCover, output[i].WaveImpactAsphaltCover);
                    Assert.AreEqual(expectedOutput[i].WaterPressureAsphaltCover, output[i].WaterPressureAsphaltCover);
                    Assert.AreEqual(expectedOutput[i].GrassCoverErosionOutwards, output[i].GrassCoverErosionOutwards);
                    Assert.AreEqual(expectedOutput[i].GrassCoverSlipOffOutwards, output[i].GrassCoverSlipOffOutwards);
                    Assert.AreEqual(expectedOutput[i].GrassCoverSlipOffInwards, output[i].GrassCoverSlipOffInwards);
                    Assert.AreEqual(expectedOutput[i].HeightStructures, output[i].HeightStructures);
                    Assert.AreEqual(expectedOutput[i].ClosingStructures, output[i].ClosingStructures);
                    Assert.AreEqual(expectedOutput[i].PipingStructure, output[i].PipingStructure);
                    Assert.AreEqual(expectedOutput[i].StabilityPointStructures, output[i].StabilityPointStructures);
                    Assert.AreEqual(expectedOutput[i].DuneErosion, output[i].DuneErosion);
                    CollectionAssert.AreEqual(expectedOutput[i].SpecificFailureMechanisms, output[i].SpecificFailureMechanisms);

                    Assert.AreEqual(expectedOutput[i].CommonSectionAssemblyMethod, output[i].CommonSectionAssemblyMethod);
                    Assert.AreEqual(expectedOutput[i].FailureMechanismResultsAssemblyMethod, output[i].FailureMechanismResultsAssemblyMethod);
                    Assert.AreEqual(expectedOutput[i].CombinedSectionResultAssemblyMethod, output[i].CombinedSectionResultAssemblyMethod);
                }
            }
        }
コード例 #20
0
        public void GivenAssessmentSectionWithReferenceLineAndOtherData_WhenImportingReferenceLine_ThenReferenceLineGeometryReplacedAndReferenceLineDependentDataCleared()
        {
            // Given
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);

            var mocks                    = new MockRepository();
            var viewCommands             = mocks.Stub <IViewCommands>();
            var failureMechanismObserver = mocks.StrictMock <IObserver>();

            failureMechanismObserver.Expect(o => o.UpdateObserver())
            .Repeat.Times(assessmentSection.GetFailureMechanisms().Count());
            var referenceLineObserver = mocks.StrictMock <IObserver>();

            referenceLineObserver.Expect(o => o.UpdateObserver());
            var surfaceLinesObserver = mocks.StrictMock <IObserver>();

            surfaceLinesObserver.Expect(o => o.UpdateObserver());
            var stochasticSoilModelsObserver = mocks.StrictMock <IObserver>();

            stochasticSoilModelsObserver.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            DataImportHelper.ImportReferenceLine(assessmentSection);
            DataImportHelper.ImportFailureMechanismSections(assessmentSection, assessmentSection.GetFailureMechanisms()
                                                            .Cast <IFailureMechanism <FailureMechanismSectionResult> >());
            DataImportHelper.ImportPipingSurfaceLines(assessmentSection);
            DataImportHelper.ImportPipingStochasticSoilModels(assessmentSection);

            ReferenceLine originalReferenceLine = assessmentSection.ReferenceLine;

            Point2D[] originalReferenceLineGeometry = originalReferenceLine.Points.ToArray();

            var    handler = new ReferenceLineUpdateHandler(assessmentSection, viewCommands);
            string path    = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO,
                                                        Path.Combine("ReferenceLine", "traject_10-2.shp"));

            var importer = new ReferenceLineImporter(assessmentSection.ReferenceLine, handler, path);

            string messageBoxTitle = null, messageBoxText = null;

            DialogBoxHandler = (name, wnd) =>
            {
                var messageBoxTester = new MessageBoxTester(wnd);

                messageBoxTitle = messageBoxTester.Title;
                messageBoxText  = messageBoxTester.Text;

                messageBoxTester.ClickOk();
            };

            assessmentSection.ReferenceLine.Attach(referenceLineObserver);
            foreach (IFailureMechanism failureMechanism in assessmentSection.GetFailureMechanisms())
            {
                failureMechanism.Attach(failureMechanismObserver);
            }

            assessmentSection.Piping.StochasticSoilModels.Attach(stochasticSoilModelsObserver);
            assessmentSection.Piping.SurfaceLines.Attach(surfaceLinesObserver);

            // When
            bool importSuccessful = importer.Import();

            importer.DoPostImport();

            // Then
            Assert.IsTrue(importSuccessful);
            Assert.AreSame(originalReferenceLine, assessmentSection.ReferenceLine);
            CollectionAssert.AreNotEqual(originalReferenceLineGeometry, assessmentSection.ReferenceLine.Points);
            Point2D[] point2Ds = assessmentSection.ReferenceLine.Points.ToArray();
            Assert.AreEqual(803, point2Ds.Length);
            Assert.AreEqual(198237.375, point2Ds[123].X, 1e-6);
            Assert.AreEqual(514879.781, point2Ds[123].Y, 1e-6);

            foreach (IFailureMechanism failureMechanism in assessmentSection.GetFailureMechanisms())
            {
                CollectionAssert.IsEmpty(failureMechanism.Sections);
            }

            CollectionAssert.IsEmpty(assessmentSection.Piping.SurfaceLines);
            CollectionAssert.IsEmpty(assessmentSection.Piping.StochasticSoilModels);
            CollectionAssert.IsEmpty(assessmentSection.Piping.CalculationsGroup.Children);

            Assert.AreEqual("Bevestigen", messageBoxTitle);
            string expectedText = "Na het importeren van een aangepaste ligging van de referentielijn zullen alle geïmporteerde en berekende gegevens van alle faalmechanismen worden gewist." + Environment.NewLine +
                                  Environment.NewLine + "Wilt u doorgaan?";

            Assert.AreEqual(expectedText, messageBoxText);

            mocks.VerifyAll();
        }