public void testNaNWithNoSource() { PercentileDef def = new PercentileDef("foo", null, 95); Assert.IsNull(def.Values); def.Timestamps = new long[] { 1 }; double[] values = def.Values; Assert.IsNotNull(values); Assert.AreEqual(1, values.Length); Assert.AreEqual(Double.NaN, values[0], 0.0f); }
/** * All these tests have a bunch of boilerplate code, encapsulated in this method * @throws RrdException */ private void commonTest(long[] timestamps, double[] inValues, double percentile, double expectedResult, String comment){ Source src = new LocalSource("bar"); src.Timestamps = timestamps; src.Values = inValues; PercentileDef def = new PercentileDef("foo", src, percentile); Assert.IsNull(def.Values); def.Timestamps = timestamps; def.Calculate(0, timestamps.Length); //Must start from 0 to use the full list of values (otherwise the aggregation uses the last 9 values) double[] outValues = def.Values; Assert.IsNotNull(outValues); //Expect as many output values as we gave timestamps Assert.AreEqual(timestamps.Length, outValues.Length); foreach (double value in outValues) { Assert.AreEqual(expectedResult, value, 0.0,comment); } }