コード例 #1
0
        protected override void Context()
        {
            _chartDisplayView    = A.Fake <IChartDisplayView>();
            _curveBinderFactory  = A.Fake <ICurveBinderFactory>();
            _exceptionManager    = A.Fake <IExceptionManager>();
            _dimensionFactory    = A.Fake <IDimensionFactory>();
            _axisBinderFactory   = A.Fake <IAxisBinderFactory>();
            _dataModeMapper      = A.Fake <ICurveToDataModeMapper>();
            _contextMenuFactory  = A.Fake <IViewItemContextMenuFactory>();
            _chartExportTask     = A.Fake <ICurveChartExportTask>();
            _applicationSettings = A.Fake <IApplicationSettings>();

            sut = new ChartDisplayPresenter(_chartDisplayView, _curveBinderFactory, _contextMenuFactory, _axisBinderFactory, _dataModeMapper, _chartExportTask, _applicationSettings);
            var dataRepository = DomainHelperForSpecs.SimulationDataRepositoryFor("Sim");

            A.CallTo(() => _dimensionFactory.MergedDimensionFor(A <DataColumn> ._)).ReturnsLazily(x => x.GetArgument <DataColumn>(0).Dimension);

            _curve = new Curve();
            _curve.SetxData(dataRepository.BaseGrid, _dimensionFactory);
            _curve.SetyData(dataRepository.AllButBaseGrid().First(), _dimensionFactory);

            A.CallTo(_curveBinderFactory).WithReturnType <ICurveBinder>().ReturnsLazily(x =>
            {
                var curve       = x.GetArgument <Curve>(0);
                var curveBinder = A.Fake <ICurveBinder>();
                A.CallTo(() => curveBinder.SeriesIds).Returns(SeriesIdsFor(curve));
                A.CallTo(() => curveBinder.LLOQ).Returns(LLOQFor(curve));
                A.CallTo(() => curveBinder.ContainsSeries(curve.Id)).Returns(true);
                A.CallTo(() => curveBinder.Id).Returns(curve.Id);
                A.CallTo(() => curveBinder.Curve).Returns(curve);
                return(curveBinder);
            });

            _curveChart = new CurveChart();
            _curveChart.AddAxis(new Axis(AxisTypes.X)
            {
                Dimension = _curve.xDimension
            });
            _curveChart.AddAxis(new Axis(AxisTypes.Y)
            {
                Dimension = _curve.yDimension
            });

            _xAxisBinder = createAxisBinderFor(_curveChart.AxisBy(AxisTypes.X));
            _yAxisBinder = createAxisBinderFor(_curveChart.AxisBy(AxisTypes.Y));

            A.CallTo(() => _axisBinderFactory.Create(_curveChart.AxisBy(AxisTypes.X), _chartDisplayView.ChartControl, _curveChart)).Returns(_xAxisBinder);
            A.CallTo(() => _axisBinderFactory.Create(_curveChart.AxisBy(AxisTypes.Y), _chartDisplayView.ChartControl, _curveChart)).Returns(_yAxisBinder);

            SetupChart();
            sut.Edit(_curveChart);
        }
コード例 #2
0
        public ICurveBinder CreateFor(Curve curve, object chartControl, CurveChart chart, IAxisBinder yAxisBinder)
        {
            var control = chartControl.DowncastTo <ChartControl>();
            var yAxis   = yAxisBinder.AxisView.DowncastTo <AxisYBase>();
            var mode    = _dataModeMapper.MapFrom(curve);

            switch (mode)
            {
            case DataMode.SingleValue:
                return(new SingleValueCurveBinder(curve, control, chart, yAxis));

            case DataMode.ArithmeticStdDev:
                return(new ArithmeticStdCurveBinder(curve, control, chart, yAxis));

            case DataMode.GeometricStdDev:
                return(new GeometricStdCurveBinder(curve, control, chart, yAxis));

            case DataMode.ArithmeticMeanArea:
                return(new ArithmeticMeanAreaCurveBinder(curve, control, chart, yAxis));

            case DataMode.GeometricMeanArea:
                return(new GeometricMeanAreaCurveBinder(curve, control, chart, yAxis));

            default:
                throw new ArgumentException($"Don't know how to build curve binder for '{mode}'");
            }
        }