Exemple #1
0
        public void Average_ReturnsAverageOfArray()
        {
            //  prerequisite
            Approx_Works();

            //  arrange
            int[]        iArr = new int[] { 0, 1, 2, 3 };
            float[]      fArr = new float[] { 0.1f, 1.1f, 2.1f, 3.1f };
            List <float> lArr = new List <float>()
            {
                0.1f, 1.1f, 2.1f, 3.1f
            };

            //  act
            float iTotal = iArr.Average();
            float fTotal = fArr.Average();
            float lTotal = lArr.Average();

            //  assert
            Assert.IsTrue(PMath.Approx(6f / 4, iTotal));
            Assert.IsTrue(PMath.Approx(6.4f / 4, fTotal));
            Assert.IsTrue(PMath.Approx(6.4f / 4, lTotal));
        }