public static void TestRandom()
		{
			int passcount = 10;
			int figureSize = 100;
			int figureSize2 = 100;
			com.esri.core.geometry.Envelope extent1 = new com.esri.core.geometry.Envelope();
			com.esri.core.geometry.Envelope extent2 = new com.esri.core.geometry.Envelope();
			com.esri.core.geometry.Envelope extent3 = new com.esri.core.geometry.Envelope();
			com.esri.core.geometry.Envelope extent4 = new com.esri.core.geometry.Envelope();
			extent1.SetCoords(-10000, 5000, 10000, 25000);
			// red
			extent2.SetCoords(-10000, 2000, 10000, 8000);
			// blue
			extent3.SetCoords(-10000, -8000, 10000, -2000);
			// blue
			extent4.SetCoords(-10000, -25000, 10000, -5000);
			// red
			com.esri.core.geometry.RandomCoordinateGenerator generator1 = new com.esri.core.geometry.RandomCoordinateGenerator(System.Math.Max(figureSize, 10000), extent1, 0.001);
			com.esri.core.geometry.RandomCoordinateGenerator generator2 = new com.esri.core.geometry.RandomCoordinateGenerator(System.Math.Max(figureSize, 10000), extent2, 0.001);
			com.esri.core.geometry.RandomCoordinateGenerator generator3 = new com.esri.core.geometry.RandomCoordinateGenerator(System.Math.Max(figureSize, 10000), extent3, 0.001);
			com.esri.core.geometry.RandomCoordinateGenerator generator4 = new com.esri.core.geometry.RandomCoordinateGenerator(System.Math.Max(figureSize, 10000), extent4, 0.001);
			System.Random random = new System.Random(1982);
			int rand_max = 511;
			int qCount = 0;
			int eCount = 0;
			int bCount = 0;
			for (int c = 0; c < passcount; c++)
			{
				com.esri.core.geometry.Polygon polyRed = new com.esri.core.geometry.Polygon();
				com.esri.core.geometry.Polygon polyBlue = new com.esri.core.geometry.Polygon();
				int r = figureSize;
				if (r < 3)
				{
					continue;
				}
				com.esri.core.geometry.Point pt;
				for (int j = 0; j < r; j++)
				{
					int rand = random.Next(rand_max);
					bool bRandomNew = (r > 10) && ((1.0 * rand) / rand_max > 0.95);
					pt = generator1.GetRandomCoord();
					if (j == 0 || bRandomNew)
					{
						polyRed.StartPath(pt);
					}
					else
					{
						polyRed.LineTo(pt);
					}
				}
				for (int j_1 = 0; j_1 < r; j_1++)
				{
					int rand = random.Next(rand_max);
					bool bRandomNew = (r > 10) && ((1.0 * rand) / rand_max > 0.95);
					pt = generator4.GetRandomCoord();
					if (j_1 == 0 || bRandomNew)
					{
						polyRed.StartPath(pt);
					}
					else
					{
						polyRed.LineTo(pt);
					}
				}
				r = figureSize2;
				if (r < 3)
				{
					continue;
				}
				for (int j_2 = 0; j_2 < r; j_2++)
				{
					int rand = random.Next(rand_max);
					bool bRandomNew = (r > 10) && ((1.0 * rand) / rand_max > 0.95);
					pt = generator2.GetRandomCoord();
					if (j_2 == 0 || bRandomNew)
					{
						polyBlue.StartPath(pt);
					}
					else
					{
						polyBlue.LineTo(pt);
					}
				}
				for (int j_3 = 0; j_3 < r; j_3++)
				{
					int rand = random.Next(rand_max);
					bool bRandomNew = (r > 10) && ((1.0 * rand) / rand_max > 0.95);
					pt = generator3.GetRandomCoord();
					if (j_3 == 0 || bRandomNew)
					{
						polyBlue.StartPath(pt);
					}
					else
					{
						polyBlue.LineTo(pt);
					}
				}
				com.esri.core.geometry.Envelope2D env = new com.esri.core.geometry.Envelope2D();
				// Quad_tree
				com.esri.core.geometry.QuadTree quadTree = BuildQuadTree(polyBlue);
				com.esri.core.geometry.QuadTree.QuadTreeIterator iterator = quadTree.GetIterator();
				com.esri.core.geometry.SegmentIteratorImpl _segIterRed = ((com.esri.core.geometry.MultiPathImpl)polyRed._getImpl()).QuerySegmentIterator();
				while (_segIterRed.NextPath())
				{
					while (_segIterRed.HasNextSegment())
					{
						com.esri.core.geometry.Segment segmentRed = _segIterRed.NextSegment();
						segmentRed.QueryEnvelope2D(env);
						iterator.ResetIterator(env, 0.001);
						while (iterator.Next() != -1)
						{
							qCount++;
						}
					}
				}
				// Envelope_2D_intersector
				System.Collections.Generic.List<com.esri.core.geometry.Envelope2D> envelopes_red = new System.Collections.Generic.List<com.esri.core.geometry.Envelope2D>();
				System.Collections.Generic.List<com.esri.core.geometry.Envelope2D> envelopes_blue = new System.Collections.Generic.List<com.esri.core.geometry.Envelope2D>();
				com.esri.core.geometry.SegmentIterator segIterRed = polyRed.QuerySegmentIterator();
				while (segIterRed.NextPath())
				{
					while (segIterRed.HasNextSegment())
					{
						com.esri.core.geometry.Segment segment = segIterRed.NextSegment();
						env = new com.esri.core.geometry.Envelope2D();
						segment.QueryEnvelope2D(env);
						envelopes_red.Add(env);
					}
				}
				com.esri.core.geometry.SegmentIterator segIterBlue = polyBlue.QuerySegmentIterator();
				while (segIterBlue.NextPath())
				{
					while (segIterBlue.HasNextSegment())
					{
						com.esri.core.geometry.Segment segment = segIterBlue.NextSegment();
						env = new com.esri.core.geometry.Envelope2D();
						segment.QueryEnvelope2D(env);
						envelopes_blue.Add(env);
					}
				}
				com.esri.core.geometry.Envelope2DIntersectorImpl intersector = new com.esri.core.geometry.Envelope2DIntersectorImpl();
				intersector.SetTolerance(0.001);
				intersector.StartRedConstruction();
				for (int i = 0; i < envelopes_red.Count; i++)
				{
					intersector.AddRedEnvelope(i, envelopes_red[i]);
				}
				intersector.EndRedConstruction();
				intersector.StartBlueConstruction();
				for (int i_1 = 0; i_1 < envelopes_blue.Count; i_1++)
				{
					intersector.AddBlueEnvelope(i_1, envelopes_blue[i_1]);
				}
				intersector.EndBlueConstruction();
				while (intersector.Next())
				{
					eCount++;
				}
				NUnit.Framework.Assert.IsTrue(qCount == eCount);
			}
		}