public void TestSolve2() { const string stopsJson = "{\"features\":[{\"geometry\":{\"x\":-122.473948,\"y\":37.7436},\"attributes\":{\"Name\":\"Office\",\"Attr_TravelTime\":0}},{\"geometry\":{\"x\":-122.439613,\"y\":37.746144},\"attributes\":{\"Name\":\"Store 1\",\"Attr_TravelTime\":25}},{\"geometry\":{\"x\":-122.488254,\"y\":37.754092},\"attributes\":{\"Name\":\"Store 2\",\"Attr_TravelTime\":20}},{\"geometry\":{\"x\":-122.44915,\"y\":37.731837},\"attributes\":{\"Name\":\"Store 3\",\"Attr_TravelTime\":30}},{\"geometry\":{\"x\":-122.46441,\"y\":37.774756},\"attributes\":{\"Name\":\"Store 4\",\"Attr_TravelTime\":25}},{\"geometry\":{\"x\":-122.426896,\"y\":37.769352},\"attributes\":{\"Name\":\"Store 5\",\"Attr_TravelTime\":20}},{\"geometry\":{\"x\":-122.473948,\"y\":37.7436},\"attributes\":{\"Name\":\"Office\",\"Attr_TravelTime\":0}}]}"; var stopFeatures = JsonConvert.DeserializeObject<FeatureSet>(stopsJson); Assert.AreEqual(stopFeatures.features.Length, 7, "There should be seven stops."); var solveParams = new SolveParameters { stopsAsFeatures = stopFeatures, findBestSequence = true, preserveFirstStop = true, preserveLastStop = true, returnDirections = true, returnRoutes = true }; var svc = new RouteService(); SolveResult result = svc.Solve(solveParams, this.Token); Assert.IsInstanceOfType(result, typeof(SolveResult)); Assert.IsNotNull(result.routes, "Routes should not be null."); Assert.IsNotNull(result.directions, "Directions should not be null."); }
public void TestSolve() { var svc = new RouteService(); var solveParameters = new SolveParameters { stops = new double[][] { new double[] {-122.4079,37.78356}, new double[] {-122.404,37.782} }, ////restrictionAttributeNames = new string[] { "none" } }; SolveResult result = svc.Solve(solveParameters, this.Token); Assert.IsInstanceOfType(result, typeof(SolveResult)); Assert.IsNotNull(result.directions, "Directions should not be null"); Assert.AreEqual(result.directions.Length, 1, "Directions should have a single element."); Direction direction = result.directions.First(); // Check some properties for expected results. Assert.AreEqual(direction.routeId, 1); Assert.AreEqual(direction.routeName, "Location 1 - Location 2"); Assert.IsTrue(direction.features.Length > 1); Assert.AreEqual(direction.features.First().attributes["maneuverType"], "esriDMTDepart"); Assert.AreEqual(direction.features.Last().attributes["maneuverType"], "esriDMTStop"); Assert.IsNotNull(result.routes); Assert.AreEqual(result.routes.spatialReference.wkid, 4326); }