예제 #1
0
        public void should_return_empty_array_if_no_prices_passed_to_calculate()
        {
            var sma    = new SimpleMovingAverage(5);
            var result = sma.Calculate(new double[] {});

            Assert.AreEqual(0, result.Length);
        }
예제 #2
0
        public void Calculate_10PointsAllOnes_1()
        {
            var calc   = new SimpleMovingAverage();
            var points = Enumerable.Repeat(1d, 10).ToList();

            var result = calc.Calculate(points);

            Assert.AreEqual(1, result);
        }
예제 #3
0
        public void Calculate_PointsIsNull_ArgumentExceptionThrown()
        {
            var calc = new SimpleMovingAverage();

            try
            {
                calc.Calculate(null);
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ArgumentException));
            }
        }
예제 #4
0
        public void Calculate_10PointsFromOneToTen_FiveAndAHalf()
        {
            var calc   = new SimpleMovingAverage();
            var points = new List <double>();

            for (int i = 0; i < 10; i++)
            {
                points.Add(i + 1);
            }

            var result = calc.Calculate(points);

            Assert.AreEqual(5.5, result);
        }