public void GenerateTownMapByRoutes_Success() { var result = _townService.GenerateTownMapByRoutes(_testRoutes); Assert.AreEqual(result.Towns.Count, 5); Assert.IsTrue(result.Towns.ContainsKey("A")); Assert.AreEqual(result.Towns["A"].RouteMap.Count, 3); }
public IActionResult GetRouteDistance([FromBody] GetRouteDistanceResponse response) { if (response == null) { return(BadRequest("Route has missing/invalid values")); } if (string.IsNullOrWhiteSpace(response.route) || response.routes == null) { return(BadRequest("Route has missing/invalid values")); } try { var townMap = _townService.GenerateTownMapByRoutes(response.routes); response.distance = _routeService.GetRouteDistance(response.route, townMap); } catch (Exception ex) { return(NotFound(ex.Message)); } return(Ok(response)); }