Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 3
0
        public void Calculate_PointsIsNull_ArgumentExceptionThrown()
        {
            var calc = new SimpleMovingAverage();

            try
            {
                calc.Calculate(null);
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ArgumentException));
            }
        }
Esempio n. 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);
        }