Exemplo n.º 1
0
        public void PIApproximator_AddEmptyPoints_ShouldThrow()
        {
            Point[]        randCollection = new Point[] { };
            PIApproximator pia            = new PIApproximator(randCollection);

            Assert.Throws <Exception>(() => pia.Approximate());
        }
Exemplo n.º 2
0
        public void PIApproximator_ApproximateFromAHundredPoints_LateAssignment()
        {
            PIApproximator pia    = new PIApproximator();
            List <Point>   points = pia.GeneratePoints(10) as List <Point>;

            pia.AddPoints(points);
            double piApproximation = pia.Approximate();
        }
Exemplo n.º 3
0
        public void PIApproximator_AddTenPoints_ShouldNotThrow()
        {
            List <Point> randCollection = new List <Point>();

            for (int i = 0; i < 10; i++)
            {
                randCollection.Add(Point.NewPoint());
            }
            PIApproximator pia = new PIApproximator(randCollection.ToArray());

            pia.Approximate();
        }
Exemplo n.º 4
0
        public void PIApproximator_Approximate_ApproximationOver2()
        {
            List <Point> randCollection = new List <Point>();

            for (int i = 0; i < 10000000; i++)
            {
                randCollection.Add(Point.NewPoint());
            }
            PIApproximator pia      = new PIApproximator(randCollection.ToArray());
            double         piApprox = pia.Approximate();

            Assert.True(piApprox > 2);
        }
Exemplo n.º 5
0
        public void PIApproximator_Approximate_ApproximationAround3dot14()
        {
            List <Point> randCollection = new List <Point>();

            for (long i = 0; i < 10000000; i++)
            {
                randCollection.Add(Point.NewPoint());
            }
            PIApproximator pia      = new PIApproximator(randCollection.ToArray());
            double         piApprox = pia.Approximate();

            // approximation around Math.PI
            Assert.True(piApprox >= (Math.PI - (Math.PI * 0.1)));
            Assert.True(piApprox <= (Math.PI + (Math.PI * 0.1)));
        }