public void TimeSeriesComparisonGraphSimpleNumericalTest()
        {
            var expected  = new TimeSeries();
            var timestamp = DateTime.Parse("2000-11-24", CultureInfo.InvariantCulture);

            expected.AddMeasurement(new Measurement
            {
                Timestamp = timestamp,
                Value     = "1"
            });
            expected.AddMeasurement(new Measurement
            {
                Timestamp = timestamp.Date.AddSeconds(1),
                Value     = "2"
            });
            var timeseriesComparison = new TimeSeriesComparison(expected, expected);
            var result = timeseriesComparison.GraphX(320, 200);

            TimeSeriesChartTest.AssertChartImage(result, SimpleResultFile, nameof(TimeSeriesComparisonGraphSimpleNumericalTest));
            var parameters = new Dictionary <string, string> {
                { "start timestamp", "2004-03-24" }
            };
            var result2 = timeseriesComparison.Graph(parameters);

            Assert.AreEqual("no data", result2);
        }
        public void TimeSeriesComparisonGraphSecondOrderResponseTest()
        {
            const double zetaExpected  = 0.205;
            const double zetaActual    = 0.2;
            const double omega         = 1;
            const double theta         = Math.PI / 2;
            var          timestampBase = DateTime.Today;
            var          minY          = double.MaxValue;
            var          maxY          = double.MinValue;

            var expected = new TimeSeries();
            var actual   = new TimeSeries();

            for (double time = 0; time <= 31; time += 0.5)
            {
                var timestamp     = timestampBase.AddSeconds(time);
                var expectedValue = TimeSeriesChartTest.SecondOrderResponse(time, zetaExpected, omega, theta);
                var actualValue   = TimeSeriesChartTest.SecondOrderResponse(time, zetaActual, omega, theta);
                if (actualValue > maxY)
                {
                    maxY = actualValue;
                }
                if (actualValue < minY)
                {
                    minY = actualValue;
                }

                var okValue = time < 12 || time > 16 && time <25 || time> 25.5;

                actual.AddMeasurement(new Measurement
                {
                    Timestamp = timestamp,
                    Value     = actualValue.To <string>(),
                    IsGood    = okValue
                });
                expected.AddMeasurement(new Measurement
                {
                    Timestamp = timestamp,
                    Value     = expectedValue.To <string>(),
                    IsGood    = true
                });
            }

            var parameters = new Dictionary <string, string>
            {
                { "Min Value", "0.7" },
                { "Max Value", "1.6" },
                { "start timestamp", timestampBase.ToRoundTripFormat() },
                { "end timestamp", timestampBase.AddSeconds(30).ToRoundTripFormat() }
            };
            var comparison = new TimeSeriesComparison(expected, actual, Tolerance.Parse("1.0"));
            var result     = comparison.Graph(parameters);

            TimeSeriesChartTest.AssertChartImage(result, SecondOrderResponseLimitedYFile, nameof(TimeSeriesComparisonGraphSecondOrderResponseTest));
            parameters.Remove("Min Value");
            parameters.Remove("Max Value");
            var result2 = new TimeSeriesComparison(expected, actual, Tolerance.Parse("1.0")).Graph(parameters);

            TimeSeriesChartTest.AssertChartImage(result2, SecondOrderResponseFile, nameof(TimeSeriesComparisonGraphSecondOrderResponseTest));
        }
        public void TimeSeriesComparisonGraphNumericalWithMissingValuesTest()
        {
            var expected  = new TimeSeries();
            var timestamp = DateTime.Parse("2000-11-24", CultureInfo.InvariantCulture);

            expected.AddMeasurement(new Measurement
            {
                Timestamp = timestamp,
                Value     = "1"
            });
            expected.AddMeasurement(new Measurement
            {
                Timestamp = timestamp.Date.AddSeconds(1),
                Value     = "2"
            });
            var actual = new TimeSeries();

            actual.AddMeasurement(new Measurement
            {
                Timestamp = timestamp,
                Value     = "1"
            });
            actual.AddMeasurement(new Measurement
            {
                Timestamp = timestamp.Date.AddSeconds(2),
                Value     = "-1"
            });
            var timeSeriesComparison = new TimeSeriesComparison(expected, actual);
            var result = timeSeriesComparison.GraphX(480, 320);

            TimeSeriesChartTest.AssertChartImage(result, MissingValuesFile, nameof(TimeSeriesComparisonGraphNumericalWithMissingValuesTest));
        }
        public void TimeSeriesComparisonGraphNumericalAllBelowXAxisTest()
        {
            var expected  = new TimeSeries();
            var timestamp = DateTime.Parse("1969-08-28", CultureInfo.InvariantCulture);

            expected.AddMeasurement(new Measurement
            {
                Timestamp = timestamp,
                Value     = "-1.2"
            });
            expected.AddMeasurement(new Measurement
            {
                Timestamp = timestamp.Date.AddSeconds(1),
                Value     = "-2.3"
            });
            var actual = new TimeSeries();

            actual.AddMeasurement(new Measurement
            {
                Timestamp = timestamp,
                Value     = "-1.2"
            });
            actual.AddMeasurement(new Measurement
            {
                Timestamp = timestamp.Date.AddSeconds(2),
                Value     = "-2.6"
            });
            var timeseriesComparison = new TimeSeriesComparison(expected, actual);
            var result = timeseriesComparison.GraphX(640, 480);

            TimeSeriesChartTest.AssertChartImage(result, AllBelowXAxisFile, nameof(TimeSeriesComparisonGraphNumericalAllBelowXAxisTest));
        }
        public void TimeSeriesComparisonGraphEmptyExpectedNumericalTest()
        {
            var expected  = new TimeSeries();
            var actual    = new TimeSeries();
            var timestamp = DateTime.Parse("2000-11-24", CultureInfo.InvariantCulture);

            actual.AddMeasurement(new Measurement
            {
                Timestamp = timestamp,
                Value     = "0"
            });
            var timeseriesComparison = new TimeSeriesComparison(expected, actual);
            var parameters           = new Dictionary <string, string>
            {
                { "Width", "320" },
                { @"heIght", "200" }
            };
            var result = timeseriesComparison.Graph(parameters);

            TimeSeriesChartTest.AssertChartImage(result, MissingExpectedFile, nameof(TimeSeriesComparisonGraphEmptyExpectedNumericalTest));
        }
 public static void ClassInitialize(TestContext testContext)
 {
     TimeSeriesChartTest.ClassInitialize(testContext);
 }