public void GivenViewWithWaternets_WhenWaternetSetEmpty_ThenNoChartData()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilProfile originalSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D();

            var calculation = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    StochasticSoilProfile = originalSoilProfile,
                    SurfaceLine           = GetSurfaceLineWithGeometry()
                },
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            using (new MacroStabilityInwardsCalculatorFactoryConfig())
                using (var control = new MacroStabilityInwardsOutputChartControl(calculation,
                                                                                 new GeneralMacroStabilityInwardsInput(),
                                                                                 AssessmentSectionTestHelper.GetTestAssessmentLevel))
                {
                    // Precondition
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertInputChartData(calculation, GetChartControl(control).Data);

                    var calculatorFactory = (TestMacroStabilityInwardsCalculatorFactory)MacroStabilityInwardsCalculatorFactory.Instance;
                    calculatorFactory.LastCreatedWaternetDailyCalculator.Output   = WaternetCalculatorResultTestFactory.CreateEmptyResult();
                    calculatorFactory.LastCreatedWaternetExtremeCalculator.Output = WaternetCalculatorResultTestFactory.CreateEmptyResult();

                    // Call
                    control.UpdateChartData();

                    // Assert
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyWaternetChartData(GetChartControl(control).Data);
                }
        }
        public void GivenCalculationWithStochasticSoilProfileAndSurfaceLine_WhenStochasticSoilProfileUpdate_ThenChartDataUpdated()
        {
            // Given
            MacroStabilityInwardsStochasticSoilProfile originalSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D();

            var calculation = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    StochasticSoilProfile = originalSoilProfile,
                    SurfaceLine           = GetSurfaceLineWithGeometry()
                },
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            using (new MacroStabilityInwardsCalculatorFactoryConfig())
                using (var control = new MacroStabilityInwardsOutputChartControl(calculation,
                                                                                 new GeneralMacroStabilityInwardsInput(),
                                                                                 AssessmentSectionTestHelper.GetTestAssessmentLevel))
                {
                    ChartDataCollection chartData = GetChartControl(control).Data;

                    // Precondition
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertInputChartData(calculation, chartData);

                    MacroStabilityInwardsStochasticSoilProfile newSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D();

                    // When
                    calculation.InputParameters.StochasticSoilProfile = newSoilProfile;
                    control.UpdateChartData();

                    // Then
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertInputChartData(calculation, chartData);
                }
        }
        public void GivenViewWithWaternets_WhenObserversNotifiedAndWaternetSame_ThenChartDataNotUpdated()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilProfile originalSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D();

            var calculation = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    StochasticSoilProfile = originalSoilProfile,
                    SurfaceLine           = GetSurfaceLineWithGeometry()
                },
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            using (new MacroStabilityInwardsCalculatorFactoryConfig())
                using (var control = new MacroStabilityInwardsOutputChartControl(calculation,
                                                                                 new GeneralMacroStabilityInwardsInput(),
                                                                                 AssessmentSectionTestHelper.GetTestAssessmentLevel))
                {
                    // Precondition
                    ChartData[] chartData = GetChartControl(control).Data.Collection.ToArray();
                    var         waternetExtremeChartDataCollection = (ChartDataCollection)chartData[waternetZonesExtremeIndex];
                    var         waternetDailyChartDataCollection   = (ChartDataCollection)chartData[waternetZonesDailyIndex];

                    MacroStabilityInwardsOutputViewChartDataAssert.AssertWaternetChartData(DerivedMacroStabilityInwardsInput.GetWaternetExtreme(calculation.InputParameters, new GeneralMacroStabilityInwardsInput(), RoundedDouble.NaN),
                                                                                           waternetExtremeChartDataCollection);
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertWaternetChartData(DerivedMacroStabilityInwardsInput.GetWaternetDaily(calculation.InputParameters, new GeneralMacroStabilityInwardsInput()),
                                                                                           waternetDailyChartDataCollection);

                    IEnumerable <ChartData> waternetExtremeChartData = waternetExtremeChartDataCollection.Collection;
                    IEnumerable <ChartData> waternetDailyChartData   = waternetDailyChartDataCollection.Collection;

                    // Call
                    control.UpdateChartData();

                    // Assert
                    CollectionAssert.AreEqual(waternetExtremeChartData, ((ChartDataCollection)chartData[waternetZonesExtremeIndex]).Collection);
                    CollectionAssert.AreEqual(waternetDailyChartData, ((ChartDataCollection)chartData[waternetZonesDailyIndex]).Collection);
                }
        }
        public void UpdateChartData_CalculationWithoutOutputWithoutWaternet_ChartDataUpdated()
        {
            // Setup
            MacroStabilityInwardsSurfaceLine           surfaceLine           = GetSurfaceLineWithGeometry();
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D();

            var calculation = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    SurfaceLine           = surfaceLine,
                    StochasticSoilProfile = stochasticSoilProfile
                },
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            using (new MacroStabilityInwardsCalculatorFactoryConfig())
                using (var control = new MacroStabilityInwardsOutputChartControl(calculation,
                                                                                 new GeneralMacroStabilityInwardsInput(),
                                                                                 AssessmentSectionTestHelper.GetTestAssessmentLevel))
                {
                    ChartDataCollection chartData = GetChartControl(control).Data;

                    // Precondition
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertInputChartData(calculation, chartData);
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertOutputChartData(calculation, chartData);

                    calculation.ClearOutput();

                    // Call
                    control.UpdateChartData();

                    // Assert
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyChartDataWithEmptySoilLayerAndWithWaternetChartData(chartData);
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyOutputChartData(chartData);
                }
        }
        public void UpdateChartData_CalculationNameChanged_ChartTitleUpdated()
        {
            // Setup
            const string newCalculationName = "Test name";

            var calculation = new MacroStabilityInwardsCalculationScenario();

            using (var control = new MacroStabilityInwardsOutputChartControl(calculation,
                                                                             new GeneralMacroStabilityInwardsInput(),
                                                                             AssessmentSectionTestHelper.GetTestAssessmentLevel))
            {
                IChartControl chartControl = GetChartControl(control);

                // Precondition
                Assert.AreEqual(calculation.Name, chartControl.ChartTitle);

                // Call
                calculation.Name = newCalculationName;
                control.UpdateChartData();

                // Assert
                Assert.AreEqual(newCalculationName, chartControl.ChartTitle);
            }
        }