Ejemplo n.º 1
0
        public void UpdateObserver_CalculationNameUpdated_ChartTitleUpdated()
        {
            // Setup
            const string initialName = "Initial name";
            const string updatedName = "Updated name";

            var calculation = new TestWaveConditionsCalculation <WaveConditionsInput>(new WaveConditionsInput())
            {
                Name = initialName
            };

            using (var view = new WaveConditionsInputView(calculation,
                                                          GetHydraulicBoundaryLocationCalculation,
                                                          new TestWaveConditionsInputViewStyle()))
            {
                // Precondition
                Assert.AreEqual(initialName, view.Chart.ChartTitle);

                calculation.Name = updatedName;

                // Call
                calculation.NotifyObservers();

                // Assert
                Assert.AreEqual(updatedName, view.Chart.ChartTitle);
            }
        }
Ejemplo n.º 2
0
        public void Constructor_ExpectedValues()
        {
            // Call
            TestWaveConditionsCalculation <WaveConditionsInput> calculation = CreateTestCalculation();

            using (var view = new WaveConditionsInputView(calculation,
                                                          GetHydraulicBoundaryLocationCalculation,
                                                          new TestWaveConditionsInputViewStyle()))
            {
                // Assert
                Assert.IsInstanceOf <UserControl>(view);
                Assert.IsInstanceOf <IChartView>(view);
                Assert.IsNotNull(view.Chart);
                Assert.AreSame(calculation, view.Data);
                Assert.AreEqual(1, view.Controls.Count);
            }
        }
Ejemplo n.º 3
0
        public void GivenViewWithInputData_WhenHydraulicBoundaryLocationCalculationChangedAndCalculationNotified_ThenUpdatedDataIsShownInChart()
        {
            // Given
            var random  = new Random(39);
            var profile = new TestForeshoreProfile(new[]
            {
                new Point2D(0.0, 0.0),
                new Point2D(1.0, 1.0),
                new Point2D(2.0, 2.0)
            });
            var calculation = new TestWaveConditionsCalculation <WaveConditionsInput>(new WaveConditionsInput())
            {
                InputParameters =
                {
                    HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(),
                    ForeshoreProfile          = profile,
                    LowerBoundaryRevetment    = (RoundedDouble)5,
                    UpperBoundaryRevetment    = (RoundedDouble)8,
                    LowerBoundaryWaterLevels  = (RoundedDouble)3,
                    UpperBoundaryWaterLevels  = (RoundedDouble)7
                }
            };

            HydraulicBoundaryLocationCalculation newHydraulicBoundaryLocationCalculation = GetHydraulicBoundaryLocationCalculation(random.NextRoundedDouble());
            HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation    = GetHydraulicBoundaryLocationCalculation(random.NextRoundedDouble());

            using (var view = new WaveConditionsInputView(calculation,
                                                          () => hydraulicBoundaryLocationCalculation,
                                                          new TestWaveConditionsInputViewStyle()))
            {
                var foreshoreChartData = (ChartLineData)view.Chart.Data.Collection.ElementAt(foreShoreChartDataIndex);
                var lowerBoundaryRevetmentChartData   = (ChartLineData)view.Chart.Data.Collection.ElementAt(lowerBoundaryRevetmentChartDataIndex);
                var upperBoundaryRevetmentChartData   = (ChartLineData)view.Chart.Data.Collection.ElementAt(upperBoundaryRevetmentChartDataIndex);
                var lowerBoundaryWaterLevelsChartData = (ChartLineData)view.Chart.Data.Collection.ElementAt(lowerBoundaryWaterLevelsChartDataIndex);
                var upperBoundaryWaterLevelsChartData = (ChartLineData)view.Chart.Data.Collection.ElementAt(upperBoundaryWaterLevelsChartDataIndex);
                var assessmentLevelChartData          = (ChartLineData)view.Chart.Data.Collection.ElementAt(assessmentLevelChartDataIndex);
                var waterLevelsChartData   = (ChartMultipleLineData)view.Chart.Data.Collection.ElementAt(waterLevelsChartDataIndex);
                var revetmentBaseChartData = (ChartLineData)view.Chart.Data.Collection.ElementAt(revetmentBaseChartDataIndex);
                var revetmentChartData     = (ChartLineData)view.Chart.Data.Collection.ElementAt(revetmentChartDataIndex);

                // When
                hydraulicBoundaryLocationCalculation = newHydraulicBoundaryLocationCalculation;
                calculation.InputParameters.NotifyObservers();
                newHydraulicBoundaryLocationCalculation.Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextRoundedDouble());
                newHydraulicBoundaryLocationCalculation.NotifyObservers();

                // Then
                Assert.AreSame(foreshoreChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(foreShoreChartDataIndex));
                Assert.AreSame(lowerBoundaryRevetmentChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(lowerBoundaryRevetmentChartDataIndex));
                Assert.AreSame(upperBoundaryRevetmentChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(upperBoundaryRevetmentChartDataIndex));
                Assert.AreSame(lowerBoundaryWaterLevelsChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(lowerBoundaryWaterLevelsChartDataIndex));
                Assert.AreSame(upperBoundaryWaterLevelsChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(upperBoundaryWaterLevelsChartDataIndex));
                Assert.AreSame(assessmentLevelChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(assessmentLevelChartDataIndex));
                Assert.AreSame(waterLevelsChartData, (ChartMultipleLineData)view.Chart.Data.Collection.ElementAt(waterLevelsChartDataIndex));
                Assert.AreSame(revetmentBaseChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(revetmentBaseChartDataIndex));
                Assert.AreSame(revetmentChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(revetmentChartDataIndex));

                AssertForeshoreChartData(profile, foreshoreChartData);

                AssertChartData(calculation.InputParameters.ForeshoreGeometry, calculation.InputParameters.LowerBoundaryRevetment,
                                lowerBoundaryRevetmentChartData, "Ondergrens bekleding");
                AssertChartData(calculation.InputParameters.ForeshoreGeometry, calculation.InputParameters.UpperBoundaryRevetment,
                                upperBoundaryRevetmentChartData, "Bovengrens bekleding");

                AssertChartData(calculation.InputParameters.ForeshoreGeometry, calculation.InputParameters.LowerBoundaryWaterLevels,
                                lowerBoundaryWaterLevelsChartData, "Ondergrens waterstanden");
                AssertChartData(calculation.InputParameters.ForeshoreGeometry, calculation.InputParameters.UpperBoundaryWaterLevels,
                                upperBoundaryWaterLevelsChartData, "Bovengrens waterstanden");

                RoundedDouble expectedAssessmentLevel = newHydraulicBoundaryLocationCalculation.Output.Result;
                AssertChartData(calculation.InputParameters.ForeshoreGeometry, expectedAssessmentLevel,
                                assessmentLevelChartData, "Waterstand bij doelkans");

                AssertWaterLevelsChartData(calculation.InputParameters.ForeshoreGeometry,
                                           calculation.InputParameters.GetWaterLevels(expectedAssessmentLevel),
                                           waterLevelsChartData);

                AssertRevetmentBaseChartData(profile.Geometry.Last(),
                                             calculation.InputParameters.LowerBoundaryRevetment,
                                             calculation.InputParameters.LowerBoundaryWaterLevels,
                                             revetmentBaseChartData);
                AssertRevetmentChartData(profile.Geometry.Last(), calculation.InputParameters.LowerBoundaryRevetment,
                                         calculation.InputParameters.UpperBoundaryRevetment, revetmentChartData);
            }
        }
Ejemplo n.º 4
0
        public void UpdateObserver_ForeshoreProfileUpdated_ChartDataUpdatedAndObserversNotified()
        {
            // Setup
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

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

            var assessmentLevel = (RoundedDouble)6;
            var calculation     = new TestWaveConditionsCalculation <WaveConditionsInput>(new WaveConditionsInput())
            {
                InputParameters =
                {
                    ForeshoreProfile         = new TestForeshoreProfile(new[]
                    {
                        new Point2D(0.0, 0.0),
                        new Point2D(1.0, 1.0),
                        new Point2D(2.0, 2.0)
                    }),
                    LowerBoundaryRevetment   = (RoundedDouble)5,
                    UpperBoundaryRevetment   = (RoundedDouble)8,
                    LowerBoundaryWaterLevels = (RoundedDouble)3,
                    UpperBoundaryWaterLevels = (RoundedDouble)7
                }
            };

            using (var view = new WaveConditionsInputView(calculation,
                                                          () => GetHydraulicBoundaryLocationCalculation(assessmentLevel),
                                                          new TestWaveConditionsInputViewStyle()))
            {
                var foreshoreChartData = (ChartLineData)view.Chart.Data.Collection.ElementAt(foreShoreChartDataIndex);
                var lowerBoundaryRevetmentChartData   = (ChartLineData)view.Chart.Data.Collection.ElementAt(lowerBoundaryRevetmentChartDataIndex);
                var upperBoundaryRevetmentChartData   = (ChartLineData)view.Chart.Data.Collection.ElementAt(upperBoundaryRevetmentChartDataIndex);
                var lowerBoundaryWaterLevelsChartData = (ChartLineData)view.Chart.Data.Collection.ElementAt(lowerBoundaryWaterLevelsChartDataIndex);
                var upperBoundaryWaterLevelsChartData = (ChartLineData)view.Chart.Data.Collection.ElementAt(upperBoundaryWaterLevelsChartDataIndex);
                var assessmentLevelChartData          = (ChartLineData)view.Chart.Data.Collection.ElementAt(assessmentLevelChartDataIndex);
                var waterLevelsChartData   = (ChartMultipleLineData)view.Chart.Data.Collection.ElementAt(waterLevelsChartDataIndex);
                var revetmentBaseChartData = (ChartLineData)view.Chart.Data.Collection.ElementAt(revetmentBaseChartDataIndex);
                var revetmentChartData     = (ChartLineData)view.Chart.Data.Collection.ElementAt(revetmentChartDataIndex);

                foreshoreChartData.Attach(observer);
                lowerBoundaryRevetmentChartData.Attach(observer);
                upperBoundaryRevetmentChartData.Attach(observer);
                lowerBoundaryWaterLevelsChartData.Attach(observer);
                upperBoundaryWaterLevelsChartData.Attach(observer);
                assessmentLevelChartData.Attach(observer);
                waterLevelsChartData.Attach(observer);
                revetmentBaseChartData.Attach(observer);
                revetmentChartData.Attach(observer);

                ForeshoreProfile profile2 = new TestForeshoreProfile(new[]
                {
                    new Point2D(0, 0),
                    new Point2D(3, 3),
                    new Point2D(8, 8)
                });

                calculation.InputParameters.ForeshoreProfile = profile2;

                // Call
                calculation.InputParameters.NotifyObservers();

                // Assert
                Assert.AreSame(foreshoreChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(foreShoreChartDataIndex));
                Assert.AreSame(lowerBoundaryRevetmentChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(lowerBoundaryRevetmentChartDataIndex));
                Assert.AreSame(upperBoundaryRevetmentChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(upperBoundaryRevetmentChartDataIndex));
                Assert.AreSame(lowerBoundaryWaterLevelsChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(lowerBoundaryWaterLevelsChartDataIndex));
                Assert.AreSame(upperBoundaryWaterLevelsChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(upperBoundaryWaterLevelsChartDataIndex));
                Assert.AreSame(assessmentLevelChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(assessmentLevelChartDataIndex));
                Assert.AreSame(waterLevelsChartData, (ChartMultipleLineData)view.Chart.Data.Collection.ElementAt(waterLevelsChartDataIndex));
                Assert.AreSame(revetmentBaseChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(revetmentBaseChartDataIndex));
                Assert.AreSame(revetmentChartData, (ChartLineData)view.Chart.Data.Collection.ElementAt(revetmentChartDataIndex));

                AssertForeshoreChartData(profile2, foreshoreChartData);

                AssertChartData(calculation.InputParameters.ForeshoreGeometry, calculation.InputParameters.LowerBoundaryRevetment,
                                lowerBoundaryRevetmentChartData, "Ondergrens bekleding");
                AssertChartData(calculation.InputParameters.ForeshoreGeometry, calculation.InputParameters.UpperBoundaryRevetment,
                                upperBoundaryRevetmentChartData, "Bovengrens bekleding");

                AssertChartData(calculation.InputParameters.ForeshoreGeometry, calculation.InputParameters.LowerBoundaryWaterLevels,
                                lowerBoundaryWaterLevelsChartData, "Ondergrens waterstanden");
                AssertChartData(calculation.InputParameters.ForeshoreGeometry, calculation.InputParameters.UpperBoundaryWaterLevels,
                                upperBoundaryWaterLevelsChartData, "Bovengrens waterstanden");

                AssertChartData(calculation.InputParameters.ForeshoreGeometry, assessmentLevel,
                                assessmentLevelChartData, "Waterstand bij doelkans");

                AssertWaterLevelsChartData(calculation.InputParameters.ForeshoreGeometry,
                                           calculation.InputParameters.GetWaterLevels(assessmentLevel),
                                           waterLevelsChartData);

                AssertRevetmentBaseChartData(profile2.Geometry.Last(),
                                             calculation.InputParameters.LowerBoundaryRevetment,
                                             calculation.InputParameters.LowerBoundaryWaterLevels,
                                             revetmentBaseChartData);
                AssertRevetmentChartData(profile2.Geometry.Last(), calculation.InputParameters.LowerBoundaryRevetment,
                                         calculation.InputParameters.UpperBoundaryRevetment, revetmentChartData);
            }

            mocks.VerifyAll();
        }
Ejemplo n.º 5
0
        public void Constructor_WithValidParameters_ChartDataSet()
        {
            // Setup
            const string calculationName = "Calculation name";
            var          assessmentLevel = (RoundedDouble)6;
            var          calculation     = new TestWaveConditionsCalculation <WaveConditionsInput>(new WaveConditionsInput())
            {
                Name            = calculationName,
                InputParameters =
                {
                    ForeshoreProfile         = new TestForeshoreProfile(new[]
                    {
                        new Point2D(0.0, 0.0),
                        new Point2D(1.0, 1.0),
                        new Point2D(2.0, 2.0)
                    }),
                    LowerBoundaryRevetment   = (RoundedDouble)5,
                    UpperBoundaryRevetment   = (RoundedDouble)8,
                    LowerBoundaryWaterLevels = (RoundedDouble)3,
                    UpperBoundaryWaterLevels = (RoundedDouble)9
                }
            };

            // Call
            using (var view = new WaveConditionsInputView(calculation,
                                                          () => GetHydraulicBoundaryLocationCalculation(assessmentLevel),
                                                          new TestWaveConditionsInputViewStyle()))
            {
                // Assert
                IChartControl chartControl = view.Chart;
                Assert.IsInstanceOf <Control>(chartControl);
                Assert.AreEqual(DockStyle.Fill, ((Control)chartControl).Dock);
                Assert.AreEqual("Afstand [m]", chartControl.BottomAxisTitle);
                Assert.AreEqual("Hoogte [m+NAP]", chartControl.LeftAxisTitle);

                Assert.AreEqual(calculationName, chartControl.ChartTitle);

                ChartDataCollection chartData = chartControl.Data;
                Assert.IsInstanceOf <ChartDataCollection>(chartData);
                Assert.AreEqual(numberOfChartDataLayers, chartData.Collection.Count());

                AssertForeshoreChartData(calculation.InputParameters.ForeshoreProfile, chartData.Collection.ElementAt(foreShoreChartDataIndex));

                AssertChartData(calculation.InputParameters.ForeshoreGeometry, calculation.InputParameters.LowerBoundaryRevetment,
                                chartData.Collection.ElementAt(lowerBoundaryRevetmentChartDataIndex), "Ondergrens bekleding");
                AssertChartData(calculation.InputParameters.ForeshoreGeometry, calculation.InputParameters.UpperBoundaryRevetment,
                                chartData.Collection.ElementAt(upperBoundaryRevetmentChartDataIndex), "Bovengrens bekleding");

                AssertChartData(calculation.InputParameters.ForeshoreGeometry, calculation.InputParameters.LowerBoundaryWaterLevels,
                                chartData.Collection.ElementAt(lowerBoundaryWaterLevelsChartDataIndex), "Ondergrens waterstanden");
                AssertChartData(calculation.InputParameters.ForeshoreGeometry, calculation.InputParameters.UpperBoundaryWaterLevels,
                                chartData.Collection.ElementAt(upperBoundaryWaterLevelsChartDataIndex), "Bovengrens waterstanden");

                AssertChartData(calculation.InputParameters.ForeshoreGeometry, assessmentLevel,
                                chartData.Collection.ElementAt(assessmentLevelChartDataIndex), "Waterstand bij doelkans");

                AssertWaterLevelsChartData(calculation.InputParameters.ForeshoreGeometry,
                                           calculation.InputParameters.GetWaterLevels(assessmentLevel),
                                           chartData.Collection.ElementAt(waterLevelsChartDataIndex));

                AssertRevetmentBaseChartData(calculation.InputParameters.ForeshoreGeometry.Last(),
                                             calculation.InputParameters.LowerBoundaryRevetment,
                                             calculation.InputParameters.LowerBoundaryWaterLevels,
                                             chartData.Collection.ElementAt(revetmentBaseChartDataIndex));
                AssertRevetmentChartData(calculation.InputParameters.ForeshoreGeometry.Last(),
                                         calculation.InputParameters.LowerBoundaryRevetment,
                                         calculation.InputParameters.UpperBoundaryRevetment,
                                         chartData.Collection.ElementAt(revetmentChartDataIndex));
            }
        }