private static void RunSpatialDistanceFilterTest(RequestDescription d, Action <GeographyPoint> verifyPoint1, Action <GeographyPoint> verifyPoint2, double distanceToReturn, int expectedCount) { bool called = false; Func <Geography, Geography, double> callback = (Geography geo1, Geography geo2) => { called = true; var point1 = geo1 as GeographyPointImplementation; Assert.IsNotNull(point1); var point2 = geo2 as GeographyPointImplementation; Assert.IsNotNull(point2); if (verifyPoint1 != null) { verifyPoint1(point1); } if (verifyPoint2 != null) { verifyPoint2(point2); } return(distanceToReturn); }; AssertConstantExpressionsAreOfPublicType(d.RequestExpression); var e = Invoke(d.RequestExpression).GetEnumerator(); using (SpatialTestUtils.RegisterOperations(new DistanceOperationImplementation(callback))) { int count = 0; while (e.MoveNext()) { count++; } Assert.IsTrue(called); Assert.AreEqual(expectedCount, count); } }