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 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 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 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 TimeSeriesComparisonGraphNoDataTest() { var comparison = new TimeSeriesComparison(null, null); var result = comparison.Graph(); Assert.AreEqual(result, "no data"); }
public void TimeSeriesComparisonDoTableExceptionTest() { var expected = new TimeSeries(); var timestamp = DateTime.Parse("2004-03-24", CultureInfo.InvariantCulture); expected.AddMeasurement(new Measurement { Timestamp = timestamp }); expected.AddMeasurement(new Measurement { Timestamp = timestamp }); var actual = new TimeSeries(); var timeSeriesComparison = new TimeSeriesComparison(expected, actual); timeSeriesComparison.DoTable(null); }
public void TimeSeriesComparisonGraphNoNumericalDataTest() { var expected = new TimeSeries(); var timestamp = DateTime.Parse("2000-11-24", CultureInfo.InvariantCulture); expected.AddMeasurement(new Measurement { Timestamp = timestamp, Value = "hi" }); var timeseriesComparison = new TimeSeriesComparison(expected, expected); var result = timeseriesComparison.Graph(); Assert.AreEqual(result, "no numeric comparison"); Assert.AreEqual(timestamp, timeseriesComparison.BaseTimestamp.DateTime); Assert.IsTrue(timeseriesComparison.TimeSpanSeconds.IsZero()); }
public void TimeSeriesComparisonQueryTest() { var timestamp = DateTime.Today; var expected = new TimeSeries(); var actual = new TimeSeries(); expected.AddMeasurement(new Measurement(timestamp, "ok", true)); actual.AddMeasurement(new Measurement(timestamp, "ok", true)); expected.AddMeasurement(new Measurement(timestamp.AddSeconds(1), "ok", true)); actual.AddMeasurement(new Measurement(timestamp.AddSeconds(1), "wrong", true)); expected.AddMeasurement(new Measurement(timestamp.AddSeconds(2), "ok", true)); actual.AddMeasurement(new Measurement(timestamp.AddSeconds(3), "ok", true)); var response = new TimeSeriesComparison(expected, actual); var actualResult = response.Query(); Assert.AreEqual(3, actualResult.Count); AssertIssue("ValueIssue", actualResult[0] as Collection <object>); AssertIssue("Missing", actualResult[1] as Collection <object>); AssertIssue("Surplus", actualResult[2] as Collection <object>); }
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 void TimeSeriesComparisonFailureCountTest() { var comparison = new TimeSeriesComparison(null, null); Assert.AreEqual(0, comparison.FailureCount); }