示例#1
0
    /**
     * 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);
        }
    }