Beispiel #1
0
        public void NumericDoublePool_Write_Works()
        {
            //Arrange
            var pool = new NumericDoublePool(10);

            //Act
            pool.Write(89);

            //Assert
            Assert.AreEqual(pool[0], 89);
        }
Beispiel #2
0
        public double Calculate(double value)
        {
            _valuePool.Write(value);

            if (_valuePool.Length >= _period)
            {
                double sum = 0;
                for (int i = 0; i < _period; i++)
                {
                    sum += _valuePool[i];
                }

                double average = sum / _period;
                WriteCopy(average);

                return(average);
            }
            else
            {
                return(double.NaN);
            }
        }