コード例 #1
0
        public void PIApproximator_GenerateTenPoints_ShouldReturnTenPointsEnumerable()
        {
            PIApproximator pia    = new PIApproximator();
            List <Point>   points = pia.GeneratePoints(10) as List <Point>;

            Assert.Equal(10, points.Count);
        }
コード例 #2
0
        public void PIApproximator_AddEmptyPoints_ShouldThrow()
        {
            Point[]        randCollection = new Point[] { };
            PIApproximator pia            = new PIApproximator(randCollection);

            Assert.Throws <Exception>(() => pia.Approximate());
        }
コード例 #3
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();
        }
コード例 #4
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();
        }
コード例 #5
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);
        }
コード例 #6
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)));
        }