コード例 #1
0
        public void GivenViewWithStochasticSoilModels_WhenStochasticSoilModelsUpdatedAndNotified_ThenMapDataUpdated()
        {
            // Given
            var failureMechanism = new PipingFailureMechanism();

            PipingFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());

            IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl;

            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("", new[]
            {
                new Point2D(1, 2),
                new Point2D(1, 2)
            });

            var stochasticSoilModelMapData = (MapLineData)map.Data.Collection.ElementAt(stochasticSoilModelsIndex);

            var mocks = new MockRepository();

            IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
            observers[stochasticSoilModelsIndex].Expect(obs => obs.UpdateObserver());
            mocks.ReplayAll();

            // When
            failureMechanism.StochasticSoilModels.AddRange(new[]
            {
                stochasticSoilModel
            }, "path");
            failureMechanism.StochasticSoilModels.NotifyObservers();

            // Then
            AssertStochasticSoilModelsMapData(failureMechanism.StochasticSoilModels, stochasticSoilModelMapData);
            mocks.VerifyAll();
        }
コード例 #2
0
        public void GivenViewWithSurfaceLineData_WhenSurfaceLineUpdatedAndNotified_ThenMapDataUpdated()
        {
            // Given
            var surfaceLine      = new PipingSurfaceLine(string.Empty);
            var failureMechanism = new PipingFailureMechanism();

            failureMechanism.SurfaceLines.AddRange(new[]
            {
                surfaceLine
            }, "path");

            PipingFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());

            IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl;

            var mocks = new MockRepository();

            IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
            observers[surfaceLinesIndex].Expect(obs => obs.UpdateObserver());
            mocks.ReplayAll();

            // When
            surfaceLine.SetGeometry(new[]
            {
                new Point3D(7, 8, 9),
                new Point3D(10, 11, 12)
            });
            surfaceLine.NotifyObservers();

            // Then
            var surfaceLineMapData = (MapLineData)map.Data.Collection.ElementAt(surfaceLinesIndex);

            AssertSurfaceLinesMapData(failureMechanism.SurfaceLines, surfaceLineMapData);
            mocks.VerifyAll();
        }
コード例 #3
0
        public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated()
        {
            // Given
            var failureMechanism = new PipingFailureMechanism();

            PipingFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());

            IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl;

            var surfaceLineA = new PipingSurfaceLine(string.Empty);

            surfaceLineA.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 1.0),
                new Point3D(3.0, 0.0, 1.7)
            });

            var surfaceLineB = new PipingSurfaceLine(string.Empty);

            surfaceLineB.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 1.5),
                new Point3D(3.0, 0.0, 1.8)
            });
            surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3);
            surfaceLineB.ReferenceLineIntersectionWorldPoint = new Point2D(1.5, 1.5);

            var calculationA =
                SemiProbabilisticPipingCalculationTestFactory.CreateCalculationWithValidInput <SemiProbabilisticPipingCalculationScenario>(
                    new TestHydraulicBoundaryLocation());
            var calculationB =
                ProbabilisticPipingCalculationTestFactory.CreateCalculationWithValidInput <ProbabilisticPipingCalculationScenario>(
                    new TestHydraulicBoundaryLocation());

            calculationA.InputParameters.SurfaceLine = surfaceLineA;
            calculationB.InputParameters.SurfaceLine = surfaceLineB;

            failureMechanism.CalculationsGroup.Children.Add(calculationA);
            failureMechanism.CalculationsGroup.Children.Add(calculationB);

            var probabilisticCalculationMapData     = (MapLineData)map.Data.Collection.ElementAt(probabilisticCalculationsIndex);
            var semiProbabilisticCalculationMapData = (MapLineData)map.Data.Collection.ElementAt(semiProbabilisticCalculationsIndex);

            var mocks = new MockRepository();

            IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
            observers[semiProbabilisticCalculationObserverIndex].Expect(obs => obs.UpdateObserver());
            observers[probabilisticCalculationObserverIndex].Expect(obs => obs.UpdateObserver());
            mocks.ReplayAll();

            // When
            failureMechanism.CalculationsGroup.Children.Add(calculationB);
            failureMechanism.CalculationsGroup.NotifyObservers();

            // Then
            AssertSemiProbabilisticCalculationsMapData(failureMechanism.Calculations.OfType <SemiProbabilisticPipingCalculationScenario>(), semiProbabilisticCalculationMapData);
            AssertProbabilisticCalculationsMapData(failureMechanism.Calculations.OfType <ProbabilisticPipingCalculationScenario>(), probabilisticCalculationMapData);
            mocks.VerifyAll();
        }
コード例 #4
0
        private PipingFailureMechanismView CreateView(PipingFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
        {
            var view = new PipingFailureMechanismView(failureMechanism, assessmentSection);

            testForm.Controls.Add(view);
            testForm.Show();

            return(view);
        }
コード例 #5
0
        public void Constructor_AssessmentSectionWithBackgroundData_BackgroundDataSet()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();

            // Call
            PipingFailureMechanismView view = CreateView(new PipingFailureMechanism(), assessmentSection);

            // Assert
            MapDataTestHelper.AssertImageBasedMapData(assessmentSection.BackgroundData, view.Map.BackgroundMapData);
        }
コード例 #6
0
        public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new PipingFailureMechanism();

            var view = new PipingFailureMechanismView(failureMechanism, assessmentSection);

            // Call
            bool closeForData = info.CloseForData(view, failureMechanism);

            // Assert
            Assert.IsTrue(closeForData);
        }
コード例 #7
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var failureMechanism  = new PipingFailureMechanism();
            var assessmentSection = new AssessmentSectionStub();

            // Call
            PipingFailureMechanismView view = CreateView(failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf <CalculationsStateFailureMechanismView>(view);
            Assert.IsNull(view.Data);
            Assert.AreSame(failureMechanism, view.FailureMechanism);
            Assert.AreSame(assessmentSection, view.AssessmentSection);
            AssertEmptyMapData(view.Map.Data);
        }
コード例 #8
0
        public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated()
        {
            // Given
            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new List <Point2D>
            {
                new Point2D(1.0, 2.0),
                new Point2D(2.0, 1.0)
            });
            var assessmentSection = new AssessmentSectionStub
            {
                ReferenceLine = referenceLine
            };

            PipingFailureMechanismView view = CreateView(new PipingFailureMechanism(), assessmentSection);

            IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl;

            var mocks = new MockRepository();

            IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
            observers[referenceLineIndex].Expect(obs => obs.UpdateObserver());
            mocks.ReplayAll();

            MapData referenceLineMapData = map.Data.Collection.ElementAt(referenceLineIndex);

            // Precondition
            MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData);

            // When
            referenceLine.SetGeometry(new List <Point2D>
            {
                new Point2D(2.0, 5.0),
                new Point2D(4.0, 3.0)
            });
            referenceLine.NotifyObservers();

            // Then
            MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData);
            mocks.VerifyAll();
        }
コード例 #9
0
        public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse()
        {
            // Setup
            var otherAssessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new PipingFailureMechanism();

            var view = new PipingFailureMechanismView(failureMechanism, assessmentSection);

            // Call
            bool closeForData = info.CloseForData(view, otherAssessmentSection);

            // Assert
            Assert.IsFalse(closeForData);

            mocks.VerifyAll();
        }
コード例 #10
0
        public void GivenViewWithFailureMechanismSectionsData_WhenFailureMechanismSectionsUpdatedAndNotified_ThenMapDataUpdated()
        {
            // Given
            var failureMechanism = new PipingFailureMechanism();

            PipingFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());

            IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl;

            IEnumerable <MapData> sectionsCollection = ((MapDataCollection)map.Data.Collection.ElementAt(sectionsCollectionIndex)).Collection;
            var sectionMapData       = (MapLineData)sectionsCollection.ElementAt(sectionsIndex);
            var sectionStartsMapData = (MapPointData)sectionsCollection.ElementAt(sectionsStartPointIndex);
            var sectionsEndsMapData  = (MapPointData)sectionsCollection.ElementAt(sectionsEndPointIndex);

            var mocks = new MockRepository();

            IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
            observers[sectionsObserverIndex].Expect(obs => obs.UpdateObserver());
            observers[sectionsStartPointObserverIndex].Expect(obs => obs.UpdateObserver());
            observers[sectionsEndPointObserverIndex].Expect(obs => obs.UpdateObserver());
            mocks.ReplayAll();

            // When
            FailureMechanismTestHelper.SetSections(failureMechanism, new[]
            {
                new FailureMechanismSection(string.Empty, new[]
                {
                    new Point2D(1, 2),
                    new Point2D(1, 2)
                })
            });
            failureMechanism.NotifyObservers();

            // Then
            MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, sectionMapData);
            MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, sectionStartsMapData);
            MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, sectionsEndsMapData);
            mocks.VerifyAll();
        }
コード例 #11
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var failureMechanism  = new PipingFailureMechanism();
            var assessmentSection = new AssessmentSectionStub();

            // Call
            PipingFailureMechanismView view = CreateView(failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf <UserControl>(view);
            Assert.IsInstanceOf <IMapView>(view);
            Assert.IsNull(view.Data);
            Assert.AreSame(failureMechanism, view.FailureMechanism);
            Assert.AreSame(assessmentSection, view.AssessmentSection);

            Assert.AreEqual(1, view.Controls.Count);
            Assert.IsInstanceOf <RiskeerMapControl>(view.Controls[0]);
            Assert.AreSame(view.Map, ((RiskeerMapControl)view.Controls[0]).MapControl);
            Assert.AreEqual(DockStyle.Fill, ((Control)view.Map).Dock);
            AssertEmptyMapData(view.Map.Data);
        }
コード例 #12
0
        public void UpdateObserver_DataUpdated_MapLayersSameOrder()
        {
            // Setup
            const int updatedReferenceLineLayerIndex            = referenceLineIndex + 7;
            const int updatedSurfaceLineLayerIndex              = surfaceLinesIndex - 1;
            const int updatedSectionCollectionIndex             = sectionsCollectionIndex - 1;
            const int updatedAssemblyResultsIndex               = assemblyResultsIndex - 1;
            const int updatedHydraulicLocationsLayerIndex       = hydraulicBoundaryLocationsIndex - 1;
            const int updatedStochasticSoilModelsLayerIndex     = stochasticSoilModelsIndex - 1;
            const int updatedProbabilisticCalculationsIndex     = probabilisticCalculationsIndex - 1;
            const int updatedSemiProbabilisticCalculationsIndex = semiProbabilisticCalculationsIndex - 1;

            var assessmentSection = new AssessmentSectionStub();

            PipingFailureMechanismView view = CreateView(new PipingFailureMechanism(), assessmentSection);

            IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl;

            MapDataCollection mapData = map.Data;

            var dataToMove = (MapLineData)map.Data.Collection.ElementAt(referenceLineIndex);

            mapData.Remove(dataToMove);
            mapData.Add(dataToMove);

            IEnumerable <MapData> mapDataCollection = mapData.Collection;

            // Precondition
            var referenceLineData = (MapLineData)mapDataCollection.ElementAt(updatedReferenceLineLayerIndex);

            Assert.AreEqual("Referentielijn", referenceLineData.Name);

            var surfaceLineData = (MapLineData)mapDataCollection.ElementAt(updatedSurfaceLineLayerIndex);

            Assert.AreEqual("Profielschematisaties", surfaceLineData.Name);

            var sectionsData = (MapDataCollection)mapDataCollection.ElementAt(updatedSectionCollectionIndex);

            Assert.AreEqual("Vakindeling", sectionsData.Name);

            var assemblyResultsData = (MapLineData)mapDataCollection.ElementAt(updatedAssemblyResultsIndex);

            Assert.AreEqual("Duidingsklasse per vak", assemblyResultsData.Name);

            var hydraulicLocationsData = (MapPointData)mapDataCollection.ElementAt(updatedHydraulicLocationsLayerIndex);

            Assert.AreEqual("Hydraulische belastingen", hydraulicLocationsData.Name);

            var stochasticSoilModelsData = (MapLineData)mapDataCollection.ElementAt(updatedStochasticSoilModelsLayerIndex);

            Assert.AreEqual("Stochastische ondergrondmodellen", stochasticSoilModelsData.Name);

            var probabilisticCalculationsData = (MapLineData)mapDataCollection.ElementAt(updatedProbabilisticCalculationsIndex);

            Assert.AreEqual("Probabilistische berekeningen", probabilisticCalculationsData.Name);

            var semiProbabilisticCalculationsData = (MapLineData)mapDataCollection.ElementAt(updatedSemiProbabilisticCalculationsIndex);

            Assert.AreEqual("Semi-probabilistische berekeningen", semiProbabilisticCalculationsData.Name);

            var points = new List <Point2D>
            {
                new Point2D(2.0, 5.0),
                new Point2D(4.0, 3.0)
            };
            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(points);
            assessmentSection.ReferenceLine = referenceLine;

            // Call
            assessmentSection.NotifyObservers();

            // Assert
            var actualReferenceLineData = (MapLineData)mapDataCollection.ElementAt(updatedReferenceLineLayerIndex);

            Assert.AreEqual("Referentielijn", actualReferenceLineData.Name);

            var actualSurfaceLineData = (MapLineData)mapDataCollection.ElementAt(updatedSurfaceLineLayerIndex);

            Assert.AreEqual("Profielschematisaties", actualSurfaceLineData.Name);

            var actualSectionsData = (MapDataCollection)mapDataCollection.ElementAt(updatedSectionCollectionIndex);

            Assert.AreEqual("Vakindeling", actualSectionsData.Name);

            var actualAssemblyResultsData = (MapLineData)mapDataCollection.ElementAt(updatedAssemblyResultsIndex);

            Assert.AreEqual("Duidingsklasse per vak", actualAssemblyResultsData.Name);

            var actualHydraulicLocationsData = (MapPointData)mapDataCollection.ElementAt(updatedHydraulicLocationsLayerIndex);

            Assert.AreEqual("Hydraulische belastingen", actualHydraulicLocationsData.Name);

            var actualStochasticSoilModelsData = (MapLineData)mapDataCollection.ElementAt(updatedStochasticSoilModelsLayerIndex);

            Assert.AreEqual("Stochastische ondergrondmodellen", actualStochasticSoilModelsData.Name);

            var actualSemiProbabilisticCalculationsData = (MapLineData)mapDataCollection.ElementAt(updatedSemiProbabilisticCalculationsIndex);

            Assert.AreEqual("Semi-probabilistische berekeningen", actualSemiProbabilisticCalculationsData.Name);

            var actualProbabilisticCalculationsData = (MapLineData)mapDataCollection.ElementAt(updatedProbabilisticCalculationsIndex);

            Assert.AreEqual("Probabilistische berekeningen", actualProbabilisticCalculationsData.Name);
        }
コード例 #13
0
        public void Constructor_WithAllData_DataUpdatedToCollectionOfFilledMapData()
        {
            // Setup
            PipingStochasticSoilModel stochasticSoilModel1 = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("name1", new[]
            {
                new Point2D(1.0, 2.0),
                new Point2D(1.1, 2.2)
            });

            PipingStochasticSoilModel stochasticSoilModel2 = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("name2", new[]
            {
                new Point2D(3.0, 4.0),
                new Point2D(3.3, 4.4)
            });

            var surfaceLineA = new PipingSurfaceLine("Line A");

            surfaceLineA.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 1.0),
                new Point3D(3.0, 0.0, 1.7)
            });

            var surfaceLineB = new PipingSurfaceLine("Name B");

            surfaceLineB.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 1.5),
                new Point3D(3.0, 0.0, 1.8)
            });
            surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3);
            surfaceLineB.ReferenceLineIntersectionWorldPoint = new Point2D(1.5, 1.5);

            var          failureMechanism  = new PipingFailureMechanism();
            const string arbitraryFilePath = "path";
            var          geometryPoints    = new[]
            {
                new Point2D(0.0, 0.0),
                new Point2D(2.0, 0.0),
                new Point2D(4.0, 4.0),
                new Point2D(6.0, 4.0)
            };

            failureMechanism.SurfaceLines.AddRange(new[]
            {
                surfaceLineA,
                surfaceLineB
            }, arbitraryFilePath);
            FailureMechanismTestHelper.SetSections(failureMechanism, new[]
            {
                new FailureMechanismSection("A", geometryPoints.Take(2)),
                new FailureMechanismSection("B", geometryPoints.Skip(1).Take(2)),
                new FailureMechanismSection("C", geometryPoints.Skip(2).Take(2))
            });
            failureMechanism.StochasticSoilModels.AddRange(new[]
            {
                stochasticSoilModel1,
                stochasticSoilModel2
            }, arbitraryFilePath);

            var hydraulicBoundaryLocation1 = new HydraulicBoundaryLocation(1, "test", 1.0, 2.0);
            var hydraulicBoundaryLocation2 = new HydraulicBoundaryLocation(2, "test", 3.0, 4.0);

            var calculationA =
                SemiProbabilisticPipingCalculationTestFactory.CreateCalculationWithValidInput <SemiProbabilisticPipingCalculationScenario>(
                    hydraulicBoundaryLocation1);
            var calculationB =
                ProbabilisticPipingCalculationTestFactory.CreateCalculationWithValidInput <ProbabilisticPipingCalculationScenario>(
                    hydraulicBoundaryLocation2);

            calculationA.InputParameters.SurfaceLine = surfaceLineA;
            calculationB.InputParameters.SurfaceLine = surfaceLineB;

            failureMechanism.CalculationsGroup.Children.Add(calculationA);
            failureMechanism.CalculationsGroup.Children.Add(calculationB);

            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(0.0, 3.0),
                new Point2D(3.0, 0.0)
            });

            var assessmentSection = new AssessmentSectionStub
            {
                ReferenceLine = referenceLine
            };

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

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                // Call
                PipingFailureMechanismView view = CreateView(failureMechanism, assessmentSection);

                IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl;

                // Assert
                MapDataCollection mapData = map.Data;
                Assert.IsInstanceOf <MapDataCollection>(mapData);

                List <MapData> mapDataList = mapData.Collection.ToList();
                Assert.AreEqual(8, mapDataList.Count);
                MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, mapDataList[referenceLineIndex]);
                AssertSurfaceLinesMapData(failureMechanism.SurfaceLines, mapDataList[surfaceLinesIndex]);

                IEnumerable <MapData> sectionsCollection = ((MapDataCollection)mapDataList[sectionsCollectionIndex]).Collection;
                MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, sectionsCollection.ElementAt(sectionsIndex));
                MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, sectionsCollection.ElementAt(sectionsStartPointIndex));
                MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, sectionsCollection.ElementAt(sectionsEndPointIndex));

                MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection, mapDataList[hydraulicBoundaryLocationsIndex]);
                AssertStochasticSoilModelsMapData(failureMechanism.StochasticSoilModels, mapDataList[stochasticSoilModelsIndex]);
                AssertProbabilisticCalculationsMapData(failureMechanism.Calculations.OfType <ProbabilisticPipingCalculationScenario>(), mapDataList[probabilisticCalculationsIndex]);
                AssertSemiProbabilisticCalculationsMapData(failureMechanism.Calculations.OfType <SemiProbabilisticPipingCalculationScenario>(), mapDataList[semiProbabilisticCalculationsIndex]);

                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
                MapDataTestHelper.AssertAssemblyMapData(failureMechanism, calculator.FailureMechanismSectionAssemblyResultOutput.AssemblyResult, mapDataList[assemblyResultsIndex]);
            }
        }