Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of <see cref="WaveConditionsInputView"/>.
        /// </summary>
        /// <param name="calculation">The calculation to show in the view.</param>
        /// <param name="getHydraulicBoundaryLocationCalculationFunc">The <see cref="Func{TResult}"/> for obtaining the <see cref="HydraulicBoundaryLocationCalculation"/>.</param>
        /// <param name="inputViewStyle">The style which should be applied to the <see cref="ChartLineData"/>.</param>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public WaveConditionsInputView(ICalculation <WaveConditionsInput> calculation,
                                       Func <HydraulicBoundaryLocationCalculation> getHydraulicBoundaryLocationCalculationFunc,
                                       IWaveConditionsInputViewStyle inputViewStyle)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (getHydraulicBoundaryLocationCalculationFunc == null)
            {
                throw new ArgumentNullException(nameof(getHydraulicBoundaryLocationCalculationFunc));
            }

            if (inputViewStyle == null)
            {
                throw new ArgumentNullException(nameof(inputViewStyle));
            }

            InitializeComponent();

            this.getHydraulicBoundaryLocationCalculationFunc = getHydraulicBoundaryLocationCalculationFunc;

            calculationObserver      = new Observer(UpdateChartTitle);
            calculationInputObserver = new Observer(UpdateCalculationInput);
            hydraulicBoundaryLocationCalculationObserver = new Observer(UpdateChartData);

            this.calculation = calculation;

            calculationObserver.Observable      = calculation;
            calculationInputObserver.Observable = calculation.InputParameters;
            hydraulicBoundaryLocationCalculationObserver.Observable = getHydraulicBoundaryLocationCalculationFunc();

            chartDataCollection               = new ChartDataCollection(RiskeerCommonFormsResources.Calculation_Input);
            foreshoreChartData                = RiskeerChartDataFactory.CreateForeshoreGeometryChartData();
            lowerBoundaryRevetmentChartData   = WaveConditionsChartDataFactory.CreateLowerRevetmentBoundaryChartData(inputViewStyle.RevetmentLineColor);
            upperBoundaryRevetmentChartData   = WaveConditionsChartDataFactory.CreateUpperRevetmentBoundaryChartData(inputViewStyle.RevetmentLineColor);
            lowerBoundaryWaterLevelsChartData = WaveConditionsChartDataFactory.CreateLowerWaterLevelsBoundaryChartData();
            upperBoundaryWaterLevelsChartData = WaveConditionsChartDataFactory.CreateUpperWaterLevelsBoundaryChartData();
            assessmentLevelChartData          = WaveConditionsChartDataFactory.CreateAssessmentLevelChartData();
            waterLevelsChartData              = WaveConditionsChartDataFactory.CreateWaterLevelsChartData();
            revetmentBaseChartData            = WaveConditionsChartDataFactory.CreateRevetmentBaseChartData(inputViewStyle.RevetmentLineColor);
            revetmentChartData                = WaveConditionsChartDataFactory.CreateRevetmentChartData(inputViewStyle.RevetmentLineColor);

            chartDataCollection.Add(foreshoreChartData);
            chartDataCollection.Add(lowerBoundaryRevetmentChartData);
            chartDataCollection.Add(upperBoundaryRevetmentChartData);
            chartDataCollection.Add(lowerBoundaryWaterLevelsChartData);
            chartDataCollection.Add(upperBoundaryWaterLevelsChartData);
            chartDataCollection.Add(assessmentLevelChartData);
            chartDataCollection.Add(waterLevelsChartData);
            chartDataCollection.Add(revetmentBaseChartData);
            chartDataCollection.Add(revetmentChartData);

            SetChartData();

            chartControl.Data = chartDataCollection;
            UpdateChartTitle();
        }
        public void CreateRevetmentChartData_ReturnsEmptyChartLineDataWithExpectedStyling()
        {
            // Setup
            Color lineColor = Color.Gray;

            // Call
            ChartLineData data = WaveConditionsChartDataFactory.CreateRevetmentChartData(lineColor);

            // Assert
            CollectionAssert.IsEmpty(data.Points);
            Assert.AreEqual("Bekleding", data.Name);
            AssertEqualStyle(data.Style, lineColor, 8, ChartLineDashStyle.Solid);
        }