Ejemplo n.º 1
0
        public void Data_WithSurfaceLineWithoutStochasticSoilProfile_CollectionOfEmptyChartDataSetForSoilProfile()
        {
            // Setup
            using (var view = new PipingInputView())
            {
                PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
                var calculation = new TestPipingCalculationScenario(new TestPipingInput())
                {
                    InputParameters =
                    {
                        SurfaceLine = surfaceLine
                    }
                };

                // Call
                view.Data = calculation;

                // Assert
                Assert.AreSame(calculation, view.Data);
                ChartDataCollection chartData = view.Chart.Data;
                Assert.IsInstanceOf <ChartDataCollection>(chartData);
                Assert.AreEqual(10, chartData.Collection.Count());
                var soilProfileData = (ChartDataCollection)chartData.Collection.ElementAt(soilProfileIndex);
                CollectionAssert.IsEmpty(soilProfileData.Collection);
                Assert.AreEqual("Ondergrondschematisatie", soilProfileData.Name);
            }
        }
Ejemplo n.º 2
0
        public void GivenPipingInputViewWithSoilProfileSeries_WhenSurfaceLineSetToNull_ThenCollectionOfEmptyChartDataSetForSoilProfiles()
        {
            // Given
            using (var view = new PipingInputView())
            {
                PipingSurfaceLine           surfaceLine           = GetSurfaceLineWithGeometry();
                PipingStochasticSoilProfile stochasticSoilProfile = GetStochasticSoilProfile();
                var calculation = new TestPipingCalculationScenario(new TestPipingInput())
                {
                    InputParameters =
                    {
                        SurfaceLine           = surfaceLine,
                        StochasticSoilProfile = stochasticSoilProfile
                    }
                };

                view.Data = calculation;

                ChartDataCollection chartData = view.Chart.Data;

                // Precondition
                Assert.IsNotNull(chartData);
                Assert.AreEqual(10, chartData.Collection.Count());
                AssertSoilProfileChartData(stochasticSoilProfile, chartData.Collection.ElementAt(soilProfileIndex), true);

                // When
                calculation.InputParameters.SurfaceLine = null;
                calculation.InputParameters.NotifyObservers();

                // Then
                AssertSoilProfileChartData(stochasticSoilProfile, chartData.Collection.ElementAt(soilProfileIndex), false);
            }
        }
Ejemplo n.º 3
0
        public void Data_SetToNull_TableDataCleared()
        {
            // Setup
            var calculation = new TestPipingCalculationScenario(new TestPipingInput())
            {
                InputParameters =
                {
                    StochasticSoilProfile = GetStochasticSoilProfile()
                }
            };

            using (var view = new PipingInputView
            {
                Data = calculation
            })
            {
                var tableControl = view.Controls.Find("pipingSoilLayerTable", true).First() as PipingSoilLayerTable;

                // Precondition
                Assert.NotNull(tableControl);
                Assert.AreEqual(3, tableControl.Rows.Count);

                // Call
                view.Data = null;

                // Assert
                Assert.IsNull(view.Data);
                CollectionAssert.IsEmpty(tableControl.Rows);
            }
        }
        public void ContextMenuStrip_FailureMechanismHasCalculationsWithOutput_ContextMenuItemClearAllOutputEnabledAndToolTipSet()
        {
            // Setup
            using (var treeViewControl = new TreeViewControl())
            {
                var pipingCalculation = new TestPipingCalculationScenario(true);

                var failureMechanism = new PipingFailureMechanism();
                failureMechanism.CalculationsGroup.Children.Add(pipingCalculation);

                var assessmentSection = mocks.Stub <IAssessmentSection>();
                var context           = new PipingFailureMechanismContext(failureMechanism, assessmentSection);

                var menuBuilder = new CustomItemsOnlyContextMenuBuilder();

                var gui = mocks.Stub <IGui>();
                gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
                gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub <IMainWindow>());
                mocks.ReplayAll();

                plugin.Gui = gui;

                failureMechanism.CalculationsGroup.Children.Add(pipingCalculation);

                // Call
                using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl))
                {
                    // Assert
                    ToolStripItem clearOutputItem = contextMenu.Items[contextMenuClearIndex];
                    Assert.IsTrue(clearOutputItem.Enabled);
                    Assert.AreEqual("Wis de uitvoer van alle berekeningen binnen dit faalmechanisme.", clearOutputItem.ToolTipText);
                }
            }
        }
Ejemplo n.º 5
0
        public void UpdateObserver_PreviousCalculationUpdated_ChartTitleNotUpdated()
        {
            // Setup
            using (var view = new PipingInputView())
            {
                const string initialName = "Initial name";
                const string updatedName = "Updated name";

                var calculation = new TestPipingCalculationScenario(new TestPipingInput())
                {
                    Name = initialName
                };

                view.Data = calculation;

                // Precondition
                Assert.AreEqual(initialName, view.Chart.ChartTitle);

                view.Data = new TestPipingCalculationScenario(new TestPipingInput())
                {
                    Name = initialName
                };

                calculation.Name = updatedName;

                // Call
                calculation.NotifyObservers();

                // Assert
                Assert.AreEqual(initialName, view.Chart.ChartTitle);
            }
        }
Ejemplo n.º 6
0
        public void EntryPointL_OnValidChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            var calculation = new TestPipingCalculationScenario();
            var entryPointL = (RoundedDouble)0.1;

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.EntryPointL = entryPointL, calculation);
        }
Ejemplo n.º 7
0
        public void PhreaticLevelExitMean_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            var calculation           = new TestPipingCalculationScenario();
            var phreaticLevelExitMean = (RoundedDouble)5.1;

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.PhreaticLevelExitMean = phreaticLevelExitMean, calculation);
        }
Ejemplo n.º 8
0
        public void DampingFactorExitMean_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            var calculation           = new TestPipingCalculationScenario();
            var dampingFactorExitMean = (RoundedDouble)2.3;

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.DampingFactorExitMean = dampingFactorExitMean, calculation);
        }
Ejemplo n.º 9
0
        public void UpdateObserver_StochasticSoilProfileUpdated_ChartDataUpdated()
        {
            // Setup
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

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

            using (var view = new PipingInputView())
            {
                PipingSurfaceLine           surfaceLine = GetSurfaceLineWithGeometry();
                PipingStochasticSoilProfile soilProfile = GetStochasticSoilProfile();
                var soilProfile2 = new PipingStochasticSoilProfile(
                    0.5, new PipingSoilProfile("profile 2", -2, new[]
                {
                    new PipingSoilLayer(0)
                    {
                        MaterialName = "Grass"
                    },
                    new PipingSoilLayer(2)
                    {
                        MaterialName = "Stone"
                    },
                    new PipingSoilLayer(3)
                    {
                        MaterialName = "Peat"
                    }
                }, SoilProfileType.SoilProfile1D));

                var calculation = new TestPipingCalculationScenario(new TestPipingInput())
                {
                    InputParameters =
                    {
                        SurfaceLine           = surfaceLine,
                        StochasticSoilProfile = soilProfile
                    }
                };

                view.Data = calculation;

                var soilProfileData = (ChartDataCollection)view.Chart.Data.Collection.ElementAt(soilProfileIndex);
                soilProfileData.Attach(observer);

                calculation.InputParameters.StochasticSoilProfile = soilProfile2;

                // Call
                calculation.InputParameters.NotifyObservers();

                // Assert
                Assert.AreSame(soilProfileData, (ChartDataCollection)view.Chart.Data.Collection.ElementAt(soilProfileIndex));
                AssertSoilProfileChartData(soilProfile2, soilProfileData, true);
                mocks.VerifyAll();
            }
        }
Ejemplo n.º 10
0
        public void StochasticSoilProfile_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            var newProfile = new PipingStochasticSoilProfile(0, PipingSoilProfileTestFactory.CreatePipingSoilProfile());
            var newValue   = new DataGridViewComboBoxItemWrapper <PipingStochasticSoilProfile>(newProfile);

            var calculation = new TestPipingCalculationScenario();

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.StochasticSoilProfile = newValue, calculation);
        }
Ejemplo n.º 11
0
        public void Calculations_AddPipingCalculation_ItemIsAddedToCollection()
        {
            // Setup
            var calculation      = new TestPipingCalculationScenario();
            var failureMechanism = new PipingFailureMechanism();

            // Call
            failureMechanism.CalculationsGroup.Children.Add(calculation);

            // Assert
            CollectionAssert.Contains(failureMechanism.CalculationsGroup.Children, calculation);
        }
Ejemplo n.º 12
0
        public void SelectableHydraulicBoundaryLocation_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            var newLocation = new TestHydraulicBoundaryLocation();
            var selectableHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(newLocation, new Point2D(0, 0));
            var newValue = new DataGridViewComboBoxItemWrapper <SelectableHydraulicBoundaryLocation>(selectableHydraulicBoundaryLocation);

            var calculation = new TestPipingCalculationScenario();

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.SelectableHydraulicBoundaryLocation = newValue, calculation);
        }
Ejemplo n.º 13
0
        public void Data_WithoutStochasticSoilProfile_SoilLayerTableEmpty()
        {
            // Setup
            using (var view = new PipingInputView())
            {
                var calculation = new TestPipingCalculationScenario(new TestPipingInput());

                // Call
                view.Data = calculation;

                // Assert
                AssertEmptySoilLayerTable(view);
            }
        }
Ejemplo n.º 14
0
        public void Calculations_RemovePipingCalculation_ItemIsRemovedFromCollection()
        {
            // Setup
            var calculation      = new TestPipingCalculationScenario();
            var failureMechanism = new PipingFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(calculation);

            // Call
            failureMechanism.CalculationsGroup.Children.Remove(calculation);

            // Assert
            CollectionAssert.DoesNotContain(failureMechanism.CalculationsGroup.Children, calculation);
        }
Ejemplo n.º 15
0
        public void Data_WithoutSurfaceLine_NoChartDataSet()
        {
            // Setup
            using (var view = new PipingInputView())
            {
                var calculation = new TestPipingCalculationScenario(new TestPipingInput());

                // Call
                view.Data = calculation;

                // Assert
                AssertEmptyChartData(view.Chart.Data);
            }
        }
Ejemplo n.º 16
0
        public void Data_PipingCalculationScenario_DataSet()
        {
            // Setup
            using (var view = new PipingInputView())
            {
                var calculation = new TestPipingCalculationScenario(new TestPipingInput());

                // Call
                view.Data = calculation;

                // Assert
                Assert.AreSame(calculation, view.Data);
            }
        }
Ejemplo n.º 17
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var calculation = new TestPipingCalculationScenario();

            // Call
            var row = new TestPipingScenarioRow(calculation);

            // Assert
            Assert.IsInstanceOf <ScenarioRow <TestPipingCalculationScenario> >(row);
            Assert.IsInstanceOf <IPipingScenarioRow>(row);
            Assert.AreSame(calculation, row.CalculationScenario);

            TestHelper.AssertTypeConverter <PipingScenarioRow <IPipingCalculationScenario <PipingInput> >, NoProbabilityValueDoubleConverter>(
                nameof(PipingScenarioRow <IPipingCalculationScenario <PipingInput> > .SectionFailureProbability));
        }
        public void GivenPipingFailureMechanismResultView_WhenNestedCalculationInputNotifiesObservers_ThenDataGridViewUpdatedAndAssemblyPerformed()
        {
            // Given
            var failureMechanism = new PipingFailureMechanism();

            FailureMechanismTestHelper.SetSections(failureMechanism, new[]
            {
                FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1")
            });

            var calculationScenario = new TestPipingCalculationScenario();
            var calculationGroup    = new CalculationGroup();

            calculationGroup.Children.Add(calculationScenario);
            failureMechanism.CalculationsGroup.Children.Add(calculationGroup);

            using (new AssemblyToolCalculatorFactoryConfig())
                using (ShowFailureMechanismResultsView(failureMechanism))
                {
                    var testFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                    FailureMechanismSectionAssemblyCalculatorStub failureMechanismSectionAssemblyCalculator = testFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
                    failureMechanismSectionAssemblyCalculator.FailureMechanismSectionAssemblyResultOutput = new FailureMechanismSectionAssemblyResultWrapper(
                        new FailureMechanismSectionAssemblyResult(1, 1, 1, FailureMechanismSectionAssemblyGroup.III),
                        AssemblyMethod.BOI0A1, AssemblyMethod.BOI0B1);

                    FailureMechanismAssemblyCalculatorStub failureMechanismAssemblyCalculator  = testFactory.LastCreatedFailureMechanismAssemblyCalculator;
                    IEnumerable <FailureMechanismSectionAssemblyResult> initialCalculatorInput = failureMechanismAssemblyCalculator.SectionAssemblyResultsInput
                                                                                                 .ToArray();

                    var          rowsChanged  = false;
                    DataGridView dataGridView = GetDataGridView();
                    dataGridView.Rows.CollectionChanged += (sender, args) => rowsChanged = true;

                    // Precondition
                    Assert.IsFalse(rowsChanged);

                    // When
                    calculationScenario.InputParameters.NotifyObservers();

                    // Then
                    Assert.IsTrue(rowsChanged);
                    IEnumerable <FailureMechanismSectionAssemblyResult> updatedCalculatorInput = failureMechanismAssemblyCalculator.SectionAssemblyResultsInput
                                                                                                 .ToArray();
                    CollectionAssert.AreNotEqual(initialCalculatorInput, updatedCalculatorInput);
                }
        }
Ejemplo n.º 19
0
        public void Data_WithSurfaceLineAndSoilProfile_DataUpdatedToCollectionOfFilledChartData()
        {
            // Setup
            using (var view = new PipingInputView())
            {
                PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
                surfaceLine.SetDitchDikeSideAt(new Point3D(1.2, 2.3, 4.0));
                surfaceLine.SetBottomDitchDikeSideAt(new Point3D(1.2, 2.3, 4.0));
                surfaceLine.SetDitchPolderSideAt(new Point3D(1.2, 2.3, 4.0));
                surfaceLine.SetBottomDitchPolderSideAt(new Point3D(1.2, 2.3, 4.0));
                surfaceLine.SetDikeToeAtPolderAt(new Point3D(1.2, 2.3, 4.0));
                surfaceLine.SetDikeToeAtRiverAt(new Point3D(1.2, 2.3, 4.0));

                PipingStochasticSoilProfile stochasticSoilProfile = GetStochasticSoilProfile();
                var calculation = new TestPipingCalculationScenario(new TestPipingInput())
                {
                    InputParameters =
                    {
                        SurfaceLine           = surfaceLine,
                        StochasticSoilProfile = stochasticSoilProfile
                    }
                };

                // Call
                view.Data = calculation;

                // Assert
                Assert.AreSame(calculation, view.Data);
                ChartDataCollection chartData = view.Chart.Data;
                Assert.IsInstanceOf <ChartDataCollection>(chartData);
                Assert.AreEqual(10, chartData.Collection.Count());
                AssertSoilProfileChartData(stochasticSoilProfile, chartData.Collection.ElementAt(soilProfileIndex), true);
                AssertSurfaceLineChartData(surfaceLine, chartData.Collection.ElementAt(surfaceLineIndex));
                AssertEntryPointLPointchartData(calculation.InputParameters, surfaceLine, chartData.Collection.ElementAt(entryPointIndex));
                AssertExitPointLPointchartData(calculation.InputParameters, surfaceLine, chartData.Collection.ElementAt(exitPointIndex));
                AssertCharacteristicPoints(surfaceLine, chartData.Collection.ToList());
            }
        }
Ejemplo n.º 20
0
        public void UpdateObserver_PreviousCalculationUpdated_ChartDataNotUpdated()
        {
            // Setup
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            mocks.ReplayAll();

            using (var view = new PipingInputView())
            {
                var calculation = new TestPipingCalculationScenario(new TestPipingInput())
                {
                    InputParameters =
                    {
                        SurfaceLine = GetSurfaceLineWithGeometry()
                    }
                };

                view.Data = calculation;

                ChartDataCollection dataBeforeUpdate = view.Chart.Data;
                foreach (ChartData chartData in dataBeforeUpdate.Collection)
                {
                    chartData.Attach(observer);
                }

                view.Data = new TestPipingCalculationScenario(new TestPipingInput());

                calculation.InputParameters.SurfaceLine = GetSecondSurfaceLineWithGeometry();

                // Call
                calculation.InputParameters.NotifyObservers();

                // Assert
                Assert.AreEqual(dataBeforeUpdate, view.Chart.Data);
                mocks.VerifyAll(); // No update observer expected
            }
        }
Ejemplo n.º 21
0
        public void UpdateObserver_DataUpdated_ChartSeriesSameOrder()
        {
            // Setup
            const int updatedSoilProfileIndex           = soilProfileIndex;
            const int updatedSurfaceLineIndex           = surfaceLineIndex + 8;
            const int updatedDitchPolderSideIndex       = ditchPolderSideIndex - 1;
            const int updatedBottomDitchPolderSideIndex = bottomDitchPolderSideIndex - 1;
            const int updatedBottomDitchDikeSideIndex   = bottomDitchDikeSideIndex - 1;
            const int updatedDitchDikeSideIndex         = ditchDikeSideIndex - 1;
            const int updatedDikeToeAtPolderIndex       = dikeToeAtPolderIndex - 1;
            const int updatedDikeToeAtRiverIndex        = dikeToeAtRiverIndex - 1;
            const int updatedExitPointIndex             = exitPointIndex - 1;
            const int updatedEntryPointIndex            = entryPointIndex - 1;

            var calculation = new TestPipingCalculationScenario(new TestPipingInput());

            using (var view = new PipingInputView
            {
                Data = calculation
            })
            {
                ChartDataCollection chartData = view.Chart.Data;

                ChartData dataToMove = chartData.Collection.ElementAt(surfaceLineIndex);
                chartData.Remove(dataToMove);
                chartData.Add(dataToMove);

                List <ChartData> chartDataList = chartData.Collection.ToList();

                var soilProfileData           = (ChartDataCollection)chartDataList[updatedSoilProfileIndex];
                var surfaceLineData           = (ChartLineData)chartDataList[updatedSurfaceLineIndex];
                var entryPointData            = (ChartPointData)chartDataList[updatedEntryPointIndex];
                var exitPointData             = (ChartPointData)chartDataList[updatedExitPointIndex];
                var ditchDikeSideData         = (ChartPointData)chartDataList[updatedDitchDikeSideIndex];
                var bottomDitchDikeSideData   = (ChartPointData)chartDataList[updatedBottomDitchDikeSideIndex];
                var ditchPolderSideData       = (ChartPointData)chartDataList[updatedDitchPolderSideIndex];
                var bottomDitchPolderSideData = (ChartPointData)chartDataList[updatedBottomDitchPolderSideIndex];
                var dikeToeAtPolderData       = (ChartPointData)chartDataList[updatedDikeToeAtPolderIndex];
                var dikeToeAtRiverData        = (ChartPointData)chartDataList[updatedDikeToeAtRiverIndex];

                Assert.AreEqual("Ondergrondschematisatie", soilProfileData.Name);
                Assert.AreEqual("Profielschematisatie", surfaceLineData.Name);
                Assert.AreEqual("Intredepunt", entryPointData.Name);
                Assert.AreEqual("Uittredepunt", exitPointData.Name);
                Assert.AreEqual("Insteek sloot dijkzijde", ditchDikeSideData.Name);
                Assert.AreEqual("Slootbodem dijkzijde", bottomDitchDikeSideData.Name);
                Assert.AreEqual("Insteek sloot polderzijde", ditchPolderSideData.Name);
                Assert.AreEqual("Slootbodem polderzijde", bottomDitchPolderSideData.Name);
                Assert.AreEqual("Teen dijk binnenwaarts", dikeToeAtPolderData.Name);
                Assert.AreEqual("Teen dijk buitenwaarts", dikeToeAtRiverData.Name);

                PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
                calculation.InputParameters.SurfaceLine = surfaceLine;

                // Call
                calculation.InputParameters.NotifyObservers();

                // Assert
                chartDataList = chartData.Collection.ToList();

                var actualSoilProfileData           = (ChartDataCollection)chartDataList[updatedSoilProfileIndex];
                var actualSurfaceLineData           = (ChartLineData)chartDataList[updatedSurfaceLineIndex];
                var actualEntryPointData            = (ChartPointData)chartDataList[updatedEntryPointIndex];
                var actualExitPointData             = (ChartPointData)chartDataList[updatedExitPointIndex];
                var actualDitchDikeSideData         = (ChartPointData)chartDataList[updatedDitchDikeSideIndex];
                var actualBottomDitchDikeSideData   = (ChartPointData)chartDataList[updatedBottomDitchDikeSideIndex];
                var actualDitchPolderSideData       = (ChartPointData)chartDataList[updatedDitchPolderSideIndex];
                var actualBottomDitchPolderSideData = (ChartPointData)chartDataList[updatedBottomDitchPolderSideIndex];
                var actualDikeToeAtPolderData       = (ChartPointData)chartDataList[updatedDikeToeAtPolderIndex];
                var actualDikeToeAtRiverData        = (ChartPointData)chartDataList[updatedDikeToeAtRiverIndex];

                Assert.AreEqual("Ondergrondschematisatie", actualSoilProfileData.Name);
                Assert.AreEqual(surfaceLine.Name, actualSurfaceLineData.Name);
                Assert.AreEqual("Intredepunt", actualEntryPointData.Name);
                Assert.AreEqual("Uittredepunt", actualExitPointData.Name);
                Assert.AreEqual("Insteek sloot dijkzijde", actualDitchDikeSideData.Name);
                Assert.AreEqual("Slootbodem dijkzijde", actualBottomDitchDikeSideData.Name);
                Assert.AreEqual("Insteek sloot polderzijde", actualDitchPolderSideData.Name);
                Assert.AreEqual("Slootbodem polderzijde", actualBottomDitchPolderSideData.Name);
                Assert.AreEqual("Teen dijk binnenwaarts", actualDikeToeAtPolderData.Name);
                Assert.AreEqual("Teen dijk buitenwaarts", actualDikeToeAtRiverData.Name);
            }
        }
Ejemplo n.º 22
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks   = new MockRepository();
            var handler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            const string calculationType = "Test";

            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 0.0),
                new Point3D(1.0, 0.0, 10)
            });

            PipingStochasticSoilModel   stochasticSoilModel   = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel();
            PipingStochasticSoilProfile stochasticSoilProfile = stochasticSoilModel.StochasticSoilProfiles.First();

            var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();

            var dampingFactorExitMean = (RoundedDouble)1.0;
            var phreaticLevelExitMean = (RoundedDouble)2.0;

            var calculation = new TestPipingCalculationScenario
            {
                InputParameters =
                {
                    DampingFactorExit         =
                    {
                        Mean                  = dampingFactorExitMean
                    },
                    PhreaticLevelExit         =
                    {
                        Mean                  = phreaticLevelExitMean
                    },
                    SurfaceLine               = surfaceLine,
                    StochasticSoilModel       = stochasticSoilModel,
                    StochasticSoilProfile     = stochasticSoilProfile,
                    HydraulicBoundaryLocation = hydraulicBoundaryLocation
                }
            };

            // Call
            var row = new PipingCalculationRow(calculation, calculationType, handler);

            // Assert
            Assert.IsInstanceOf <CalculationRow <IPipingCalculationScenario <PipingInput> > >(row);

            Assert.AreSame(calculation, row.Calculation);
            Assert.AreEqual(calculation.Name, row.Name);
            Assert.AreEqual(calculationType, row.CalculationType);
            Assert.AreSame(stochasticSoilModel, row.StochasticSoilModel.WrappedObject);
            Assert.AreSame(stochasticSoilProfile, row.StochasticSoilProfile.WrappedObject);
            Assert.AreEqual(2, row.StochasticSoilProfileProbability.NumberOfDecimalPlaces);
            Assert.AreEqual(stochasticSoilProfile.Probability * 100, row.StochasticSoilProfileProbability, row.StochasticSoilProfileProbability.GetAccuracy());
            Assert.AreSame(hydraulicBoundaryLocation, row.SelectableHydraulicBoundaryLocation.WrappedObject.HydraulicBoundaryLocation);
            Assert.AreEqual(dampingFactorExitMean, row.DampingFactorExitMean);
            Assert.AreEqual(phreaticLevelExitMean, row.PhreaticLevelExitMean);
            Assert.AreEqual(calculation.InputParameters.EntryPointL, row.EntryPointL);
            Assert.AreEqual(calculation.InputParameters.ExitPointL, row.ExitPointL);
            mocks.VerifyAll();
        }
        public void ContextMenuStrip_FailureMechanismHasCalculationWithOutput_ReturnsContextMenuWithCommonItems()
        {
            // Setup
            var failureMechanism  = new TestPipingFailureMechanism();
            var pipingCalculation = new TestPipingCalculationScenario(true);

            failureMechanism.CalculationsGroup.Children.Add(pipingCalculation);

            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var context           = new PipingFailureMechanismContext(failureMechanism, assessmentSection);

            var applicationFeatureCommandHandler = mocks.Stub <IApplicationFeatureCommands>();
            var importCommandHandler             = mocks.Stub <IImportCommandHandler>();
            var exportCommandHandler             = mocks.Stub <IExportCommandHandler>();
            var updateCommandHandler             = mocks.Stub <IUpdateCommandHandler>();
            var viewCommandsHandler = mocks.Stub <IViewCommands>();

            using (var treeViewControl = new TreeViewControl())
            {
                var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler,
                                                         importCommandHandler,
                                                         exportCommandHandler,
                                                         updateCommandHandler,
                                                         viewCommandsHandler,
                                                         context,
                                                         treeViewControl);

                var gui = mocks.Stub <IGui>();
                gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
                gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub <IMainWindow>());
                mocks.ReplayAll();

                plugin.Gui = gui;

                // Call
                using (ContextMenuStrip menu = info.ContextMenuStrip(context, null, treeViewControl))
                {
                    // Assert
                    Assert.AreEqual(12, menu.Items.Count);

                    TestHelper.AssertContextMenuStripContainsItem(menu,
                                                                  0,
                                                                  "&Openen",
                                                                  "Open de gegevens in een nieuw documentvenster.",
                                                                  CoreGuiResources.OpenIcon,
                                                                  false);

                    TestHelper.AssertContextMenuStripContainsItem(menu,
                                                                  2,
                                                                  "Alles &valideren",
                                                                  "Valideer alle berekeningen binnen dit faalmechanisme.",
                                                                  RiskeerCommonFormsResources.ValidateAllIcon);
                    TestHelper.AssertContextMenuStripContainsItem(menu,
                                                                  3,
                                                                  "Alles be&rekenen",
                                                                  "Voer alle berekeningen binnen dit faalmechanisme uit.",
                                                                  RiskeerCommonFormsResources.CalculateAllIcon);
                    TestHelper.AssertContextMenuStripContainsItem(menu,
                                                                  5,
                                                                  "&Wis alle uitvoer...",
                                                                  "Wis de uitvoer van alle berekeningen binnen dit faalmechanisme.",
                                                                  RiskeerCommonFormsResources.ClearIcon);

                    TestHelper.AssertContextMenuStripContainsItem(menu,
                                                                  6,
                                                                  "Wis alle illustratiepunten...",
                                                                  "Er zijn geen berekeningen met illustratiepunten om te wissen.",
                                                                  RiskeerCommonFormsResources.ClearIllustrationPointsIcon,
                                                                  false);

                    TestHelper.AssertContextMenuStripContainsItem(menu,
                                                                  8,
                                                                  "Alles i&nklappen",
                                                                  "Klap dit element en alle onderliggende elementen in.",
                                                                  CoreGuiResources.CollapseAllIcon,
                                                                  false);
                    TestHelper.AssertContextMenuStripContainsItem(menu,
                                                                  9,
                                                                  "Alles ui&tklappen",
                                                                  "Klap dit element en alle onderliggende elementen uit.",
                                                                  CoreGuiResources.ExpandAllIcon,
                                                                  false);

                    TestHelper.AssertContextMenuStripContainsItem(menu,
                                                                  11,
                                                                  "Ei&genschappen",
                                                                  "Toon de eigenschappen in het Eigenschappenpaneel.",
                                                                  CoreGuiResources.PropertiesHS,
                                                                  false);

                    CollectionAssert.AllItemsAreInstancesOfType(new[]
                    {
                        menu.Items[1],
                        menu.Items[4],
                        menu.Items[7],
                        menu.Items[10]
                    }, typeof(ToolStripSeparator));
                }
            }
        }
Ejemplo n.º 24
0
        public void UpdateObserver_CalculationSurfaceLineUpdated_ChartDataUpdated()
        {
            // Setup
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver()).Repeat.Times(9);
            mocks.ReplayAll();

            using (var view = new PipingInputView())
            {
                var characteristicPoint       = new Point3D(1.2, 2.3, 4.0);
                PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();

                surfaceLine.SetDitchDikeSideAt(characteristicPoint);
                surfaceLine.SetBottomDitchDikeSideAt(characteristicPoint);
                surfaceLine.SetDitchPolderSideAt(characteristicPoint);
                surfaceLine.SetBottomDitchPolderSideAt(characteristicPoint);
                surfaceLine.SetDikeToeAtPolderAt(characteristicPoint);
                surfaceLine.SetDikeToeAtRiverAt(characteristicPoint);

                var calculation = new TestPipingCalculationScenario(new TestPipingInput())
                {
                    InputParameters =
                    {
                        SurfaceLine = surfaceLine
                    }
                };

                view.Data = calculation;

                List <ChartData> chartDataList = view.Chart.Data.Collection.ToList();
                var surfaceLineChartData       = (ChartLineData)chartDataList[surfaceLineIndex];
                var entryPointChartData        = (ChartPointData)chartDataList[entryPointIndex];
                var exitPointChartData         = (ChartPointData)chartDataList[exitPointIndex];
                var ditchDikeSideData          = (ChartPointData)chartDataList[ditchDikeSideIndex];
                var bottomDitchDikeSideData    = (ChartPointData)chartDataList[bottomDitchDikeSideIndex];
                var ditchPolderSideData        = (ChartPointData)chartDataList[ditchPolderSideIndex];
                var bottomDitchPolderSideData  = (ChartPointData)chartDataList[bottomDitchPolderSideIndex];
                var dikeToeAtPolderData        = (ChartPointData)chartDataList[dikeToeAtPolderIndex];
                var dikeToeAtRiverData         = (ChartPointData)chartDataList[dikeToeAtRiverIndex];

                surfaceLineChartData.Attach(observer);
                entryPointChartData.Attach(observer);
                exitPointChartData.Attach(observer);
                ditchDikeSideData.Attach(observer);
                bottomDitchDikeSideData.Attach(observer);
                ditchPolderSideData.Attach(observer);
                bottomDitchPolderSideData.Attach(observer);
                dikeToeAtPolderData.Attach(observer);
                dikeToeAtRiverData.Attach(observer);

                var characteristicPoint2       = new Point3D(3.5, 2.3, 8.0);
                PipingSurfaceLine surfaceLine2 = GetSecondSurfaceLineWithGeometry();

                surfaceLine2.SetDitchDikeSideAt(characteristicPoint2);
                surfaceLine2.SetBottomDitchDikeSideAt(characteristicPoint2);
                surfaceLine2.SetDitchPolderSideAt(characteristicPoint2);
                surfaceLine2.SetBottomDitchPolderSideAt(characteristicPoint2);
                surfaceLine2.SetDikeToeAtPolderAt(characteristicPoint2);
                surfaceLine2.SetDikeToeAtRiverAt(characteristicPoint2);

                calculation.InputParameters.SurfaceLine = surfaceLine2;

                // Call
                calculation.InputParameters.NotifyObservers();

                // Assert
                chartDataList = view.Chart.Data.Collection.ToList();

                Assert.AreSame(surfaceLineChartData, (ChartLineData)chartDataList[surfaceLineIndex]);
                Assert.AreSame(entryPointChartData, (ChartPointData)chartDataList[entryPointIndex]);
                Assert.AreSame(exitPointChartData, (ChartPointData)chartDataList[exitPointIndex]);
                Assert.AreSame(ditchDikeSideData, (ChartPointData)chartDataList[ditchDikeSideIndex]);
                Assert.AreSame(bottomDitchDikeSideData, (ChartPointData)chartDataList[bottomDitchDikeSideIndex]);
                Assert.AreSame(ditchPolderSideData, (ChartPointData)chartDataList[ditchPolderSideIndex]);
                Assert.AreSame(bottomDitchPolderSideData, (ChartPointData)chartDataList[bottomDitchPolderSideIndex]);
                Assert.AreSame(dikeToeAtPolderData, (ChartPointData)chartDataList[dikeToeAtPolderIndex]);
                Assert.AreSame(dikeToeAtRiverData, (ChartPointData)chartDataList[dikeToeAtRiverIndex]);

                AssertSurfaceLineChartData(surfaceLine2, surfaceLineChartData);
                AssertEntryPointLPointchartData(calculation.InputParameters, surfaceLine2, entryPointChartData);
                AssertExitPointLPointchartData(calculation.InputParameters, surfaceLine2, exitPointChartData);
                AssertCharacteristicPoints(surfaceLine2, chartDataList);
                mocks.VerifyAll();
            }
        }
        public void GivenMultiplePipingCalculationsWithOutput_WhenClearingOutputFromContextMenu_ThenPipingOutputCleared(bool confirm)
        {
            // Given
            using (var treeViewControl = new TreeViewControl())
            {
                var pipingCalculation1 = new TestPipingCalculationScenario(true);
                var pipingCalculation2 = new TestPipingCalculationScenario(true);

                var observer = mocks.StrictMock <IObserver>();
                if (confirm)
                {
                    observer.Expect(o => o.UpdateObserver()).Repeat.Twice();
                }

                var failureMechanism = new PipingFailureMechanism();
                failureMechanism.CalculationsGroup.Children.Add(pipingCalculation1);
                failureMechanism.CalculationsGroup.Children.Add(pipingCalculation2);

                var assessmentSection = mocks.Stub <IAssessmentSection>();
                var context           = new PipingFailureMechanismContext(failureMechanism, assessmentSection);

                var menuBuilder = new CustomItemsOnlyContextMenuBuilder();

                var gui = mocks.Stub <IGui>();
                gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
                gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub <IMainWindow>());
                mocks.ReplayAll();

                plugin.Gui = gui;

                failureMechanism.CalculationsGroup.Children.Add(pipingCalculation1);
                failureMechanism.CalculationsGroup.Children.Add(pipingCalculation2);
                failureMechanism.CalculationsGroup.Children.ElementAt(0).Attach(observer);
                failureMechanism.CalculationsGroup.Children.ElementAt(1).Attach(observer);

                string messageBoxTitle = null, messageBoxText = null;
                DialogBoxHandler = (name, wnd) =>
                {
                    var messageBox = new MessageBoxTester(wnd);

                    messageBoxText  = messageBox.Text;
                    messageBoxTitle = messageBox.Title;

                    if (confirm)
                    {
                        messageBox.ClickOk();
                    }
                    else
                    {
                        messageBox.ClickCancel();
                    }
                };

                using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(context, null, treeViewControl))
                {
                    // When
                    contextMenuStrip.Items[contextMenuClearIndex].PerformClick();

                    // Then
                    foreach (ICalculation calc in failureMechanism.CalculationsGroup.Children.OfType <ICalculation>())
                    {
                        Assert.AreNotEqual(confirm, calc.HasOutput);
                    }

                    Assert.AreEqual("Bevestigen", messageBoxTitle);
                    Assert.AreEqual("Weet u zeker dat u alle uitvoer wilt wissen?", messageBoxText);
                }
            }
        }