public void ShouldPassCorrectInputValuesToTheCalculatorWhenSuccessfulyLoadData() { ScatterInputData actualInputData = null; var expectedInputData = new ScatterInputData { Data = new[] { new Dictionary <string, double> { { "seven", 0.00052 }, { "eight", 1.000012 }, { "nine", 1.1 } }, new Dictionary <string, double> { { "seven", 0.0000010101 }, { "eight", 0.12456 }, { "nine", 1.2 } } }, AbscissaColumnName = "seven", OrdinateColumnName = "eight" }; var dataResult = DataResult.CreateSuccessful(expectedInputData.Data); FakeProvider.GetFrom(null).ReturnsForAnyArgs(dataResult); var dummyReportData = new ScatterReportData(Enumerable.Empty <ScatterPoint>(), new ScatterLine(new ScatterPoint(), new ScatterPoint())); FakeScatterReportCalculator.Calculate(Arg.Do <ScatterInputData>(input => actualInputData = input)).ReturnsForAnyArgs(dummyReportData); ViewModel.LoadDataCommand.Execute("dummy.path"); SelectColumnsForReport("seven", "eight"); ViewModel.GenerateReportDataCommand.Execute(null); actualInputData.ShouldBeEquivalentTo(expectedInputData); }
public void MaxPoint_ShouldReturnZeroPointWhenNoPointsProvided() { var points = Enumerable.Empty <ScatterPoint>(); var expectedMinPoint = new ScatterPoint(0, 0); var report = new ScatterReportData(points, _dummyLine); report.MaxPoint.Should().Be(expectedMinPoint); }
public MainViewModel(IDataProvider provider, IScatterReportCalculator calculator) { _provider = provider; _calculator = calculator; Columns = new ReadOnlyCollection <DataColumnViewModel>(new List <DataColumnViewModel>()); Report = new ScatterReportData(Enumerable.Empty <ScatterPoint>(), ScatterLine.Zero); LoadDataCommand = new Command(param => LoadData((string)param)); GenerateReportDataCommand = new Command(param => GenerateReportData(), param => IsAllRequiredColumnsSelected()); ToggleColumnSelectionCommand = new Command(column => ToggleColumnSelection((DataColumnViewModel)column)); }
public void MaxPoint_ShouldReturnPointWithMinXAndYValues() { var points = new[] { new ScatterPoint(2.90, 1.0009), new ScatterPoint(2.9991, 0.009), new ScatterPoint(12.897, 0.009) }; var expectedMinPoint = new ScatterPoint(12.897, 1.0009); var report = new ScatterReportData(points, _dummyLine); report.MaxPoint.Should().Be(expectedMinPoint); }
public void MinPoint_ShouldReturnPointWithMinXAndYValues() { var points = new[] { new ScatterPoint(10, 12), new ScatterPoint(13, 34), new ScatterPoint(2, 24) }; var expectedMinPoint = new ScatterPoint(2, 12); var report = new ScatterReportData(points, _dummyLine); report.MinPoint.Should().Be(expectedMinPoint); }
public void Calculate_ShouldReturnEmptyReportWhenGivenDataIsEmpty() { var inputData = new ScatterInputData { Data = Enumerable.Empty <Dictionary <string, double> >(), AbscissaColumnName = "first", OrdinateColumnName = "second" }; var expectedReport = new ScatterReportData(Enumerable.Empty <ScatterPoint>(), new ScatterLine(new ScatterPoint(), new ScatterPoint())); var actualReport = _calculator.Calculate(inputData); actualReport.ShouldBeEquivalentTo(expectedReport); }
public void ShouldUpdateReportData() { var plotPoints = new[] { new ScatterPoint(1.23, 1.9), new ScatterPoint(1.59, 24.5), new ScatterPoint(0.5, 15), }; var trendLine = new ScatterLine(new ScatterPoint(1, 12.12), new ScatterPoint(2, 16.34)); var reportData = new ScatterReportData(plotPoints, trendLine); FakeScatterReportCalculator.Calculate(Arg.Any <ScatterInputData>()).Returns(reportData); ViewModel.GenerateReportDataCommand.Execute(null); ViewModel.Report.ShouldBeEquivalentTo(reportData); }
public void ShouldRaisePropertyChangedForReportDataCollection() { var plotPoints = new[] { new ScatterPoint(1, 2), new ScatterPoint(42, 22), new ScatterPoint(2, 3), }; var trendLine = new ScatterLine(new ScatterPoint(1, 4), new ScatterPoint(32, 22)); var reportData = new ScatterReportData(plotPoints, trendLine); FakeScatterReportCalculator.Calculate(Arg.Any <ScatterInputData>()).Returns(reportData); ViewModel.MonitorEvents(); ViewModel.GenerateReportDataCommand.Execute(null); ViewModel.ShouldRaisePropertyChangeFor(viewmodel => viewmodel.ReportDataCollection); }
public void ShouldRaisePropertyChangedForReportData() { var plotPoints = new[] { new ScatterPoint(1.23, 1.9), new ScatterPoint(1.59, 24.5), new ScatterPoint(0.5, 15), }; var trendLine = new ScatterLine(new ScatterPoint(1, 12.12), new ScatterPoint(2, 16.34)); var reportData = new ScatterReportData(plotPoints, trendLine); FakeScatterReportCalculator.Calculate(Arg.Any <ScatterInputData>()).Returns(reportData); ViewModel.MonitorEvents(); ViewModel.GenerateReportDataCommand.Execute(null); ViewModel.ShouldRaisePropertyChangeFor(viewmodel => viewmodel.Report); }
public void ShouldContainCalculatedTrendLine() { var plotPoints = new[] { new ScatterPoint(1.0, 0.20), new ScatterPoint(4.2, 0.22), new ScatterPoint(2.0, 1.31), }; var trendLine = new ScatterLine(new ScatterPoint(1, 4), new ScatterPoint(32, 22)); var reportData = new ScatterReportData(plotPoints, trendLine); FakeScatterReportCalculator.Calculate(Arg.Any <ScatterInputData>()).Returns(reportData); ViewModel.GenerateReportDataCommand.Execute(null); var actualLine = ViewModel.ReportDataCollection.OfType <ScatterLine>().First(); actualLine.ShouldBeEquivalentTo(trendLine); }
public void ShouldContainAllCalculatedPlotPoints() { var plotPoints = new[] { new ScatterPoint(1, 2), new ScatterPoint(42, 22), new ScatterPoint(2, 3), }; var trendLine = new ScatterLine(new ScatterPoint(1, 4), new ScatterPoint(32, 22)); var reportData = new ScatterReportData(plotPoints, trendLine); FakeScatterReportCalculator.Calculate(Arg.Any <ScatterInputData>()).Returns(reportData); ViewModel.GenerateReportDataCommand.Execute(null); var actualPoints = ViewModel.ReportDataCollection.OfType <ScatterPoint>(); actualPoints.ShouldBeEquivalentTo(plotPoints); }