public void Calculate_ShouldReturnExpectedTrendLinePointsWithEvenCorrelation()
        {
            var data = new[]
            {
                new Dictionary <string, double> {
                    { "first", 61 }, { "second", 1.40714182621643 }
                },
                new Dictionary <string, double> {
                    { "first", 75 }, { "second", 1.67869994337439 }
                },
                new Dictionary <string, double> {
                    { "first", 26 }, { "second", 1.86521975662936 }
                },
                new Dictionary <string, double> {
                    { "first", 65 }, { "second", 1.96665785281196 }
                },
                new Dictionary <string, double> {
                    { "first", 28 }, { "second", 1.48216295762807 }
                }
            };
            var expectedTrendLine = new ScatterLine(new ScatterPoint(26, 1.6660), new ScatterPoint(75, 1.6954));
            var inputData         = new ScatterInputData {
                Data = data, AbscissaColumnName = "first", OrdinateColumnName = "second"
            };

            AssertThatTrendLineCalculatedCorrectly(inputData, expectedTrendLine);
        }
        public void Calculate_ShouldReturnExpectedTrendLinePointsWithPositiveCorrelation()
        {
            var data = new[]
            {
                new Dictionary <string, double> {
                    { "first", 10 }, { "second", 1.2 }, { "third", 22.2 }, { "fourth", 10 }
                },
                new Dictionary <string, double> {
                    { "first", 15 }, { "second", 0.2 }, { "third", 33.879401 }, { "fourth", 20 }
                },
                new Dictionary <string, double> {
                    { "first", 20 }, { "second", 0.598 }, { "third", 28.59 }, { "fourth", 30 }
                },
                new Dictionary <string, double> {
                    { "first", 35 }, { "second", 1.4 }, { "third", 29.2 }, { "fourth", 40 }
                },
                new Dictionary <string, double> {
                    { "first", 40 }, { "second", 1.221 }, { "third", 28 }, { "fourth", 50 }
                }
            };
            var expectedTrendLine = new ScatterLine(new ScatterPoint(10, 13.2833), new ScatterPoint(40, 49.1033));
            var inputData         = new ScatterInputData {
                Data = data, AbscissaColumnName = "first", OrdinateColumnName = "fourth"
            };

            AssertThatTrendLineCalculatedCorrectly(inputData, expectedTrendLine);
        }
        public void Calculate_ShouldReturnExpectedTrendLinePointsWithNegativeCorrelation()
        {
            var data = new[]
            {
                new Dictionary <string, double> {
                    { "first", 10 }, { "second", 50 }
                },
                new Dictionary <string, double> {
                    { "first", 20 }, { "second", 40 }
                },
                new Dictionary <string, double> {
                    { "first", 30 }, { "second", 30 }
                },
                new Dictionary <string, double> {
                    { "first", 40 }, { "second", 20 }
                },
                new Dictionary <string, double> {
                    { "first", 50 }, { "second", 10 }
                }
            };
            var expectedTrendLine = new ScatterLine(new ScatterPoint(10, 50), new ScatterPoint(50, 10));
            var inputData         = new ScatterInputData {
                Data = data, AbscissaColumnName = "first", OrdinateColumnName = "second"
            };

            AssertThatTrendLineCalculatedCorrectly(inputData, expectedTrendLine);
        }
Exemplo n.º 4
0
        private ScatterReportData GenerateDummyReportData()
        {
            var points = new[]
            {
                new ScatterPoint(1.2, 4.3),
                new ScatterPoint(1.3, 4.2),
                new ScatterPoint(1.4, 4.1),
                new ScatterPoint(1.5, 4.0)
            };
            var trendLine = new ScatterLine(new ScatterPoint(1.0, 4.15), new ScatterPoint(1.5, 4.15));

            return(new ScatterReportData(points, trendLine));
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
        private void AssertThatTrendLineCalculatedCorrectly(ScatterInputData inputData, ScatterLine expectedLine)
        {
            var actualReport = _calculator.Calculate(inputData);

            actualReport.TrendLine.ShouldBeEquivalentTo(expectedLine, TestUtils.DoubleShouldBeEqualApproximately);
        }