Ejemplo n.º 1
0
        public void FlowMeterEarlyOutlierTest()
        {
            var flowMeter = new FlowMeter();

            flowMeter.AddMeasurement(new Measurement(DateTime.Now, 5000, 0));
            flowMeter.AddMeasurement(new Measurement(DateTime.Now, 2500, 0));
            var expected = new FlowMeter
            {
                Amplitude           = 2500,
                Outlier             = true,
                FirstOutlier        = true,
                HighPass            = 0,
                LowPassOnHighPass   = 0,
                CalculatedFlow      = false,
                LowPassSlow         = 2500,
                LowPassFast         = 2500,
                LowPassDifference   = 0,
                LowPassOnDifference = 0,
                Drift      = false,
                Exclude    = true,
                Flow       = false,
                ExcludeAll = true
            };

            AssertResultsAreEqual(expected, flowMeter, "Early outlier reset");

            flowMeter.AddMeasurement(new Measurement(DateTime.Now, 2510, 0));
            expected.Amplitude    = 0;
            expected.Outlier      = false;
            expected.FirstOutlier = false;
            expected.LowPassSlow  = 2510;
            expected.LowPassFast  = 2510;
            expected.Exclude      = false;
            expected.ExcludeAll   = false;
            AssertResultsAreEqual(expected, flowMeter, "First after outlier reset");

            flowMeter.AddMeasurement(new Measurement(DateTime.Now, 2490, 0));
            expected.Amplitude           = 20;
            expected.HighPass            = -10;
            expected.LowPassOnHighPass   = 2;
            expected.LowPassSlow         = 2509.4;
            expected.LowPassFast         = 2508;
            expected.LowPassDifference   = 1.4;
            expected.LowPassOnDifference = 0.14;

            AssertResultsAreEqual(expected, flowMeter, "Second after outlier reset");
        }
Ejemplo n.º 2
0
 private static void AssessAfterSeries(FlowMeter flowMeter, int count, Func <int, int> value, string description, IAnalysisResult expected)
 {
     for (var i = 0; i < count; i++)
     {
         flowMeter.AddMeasurement(new Measurement(DateTime.Now, value(i), 1500));
     }
     AssertResultsAreEqual(expected, flowMeter, description);
 }