static void Main(string[] args) { AppLog.ConfigureLogging(); // TODO: Create entry points into the code like git/dotnet: // `aa weather <lon> <lat>` // `aa mapData <lon> <lat> <size>` or `aa mapData <n> <e> <s> <w>` if (args.Length != 1) { log.Info("Application requires an Altitude Angel API key to be supplied!!"); NLog.LogManager.Shutdown(); Environment.Exit(1); } // Create an Authorization header with the CLI supplied API key. string apiKey = args[0]; AltitudeAngelApi aaClient = new AltitudeAngelApi(apiKey); // Synchronous call the async function for the HTTP Response. // FIXME: don't hard-code coordinates. MapData response = aaClient.GetMapData( 51.46227963315035, -0.9569686575500782, 51.450125805383585, -0.9857433958618458).Result; List <string> names = new List <string>();; foreach (Feature feature in response.features) { names.Add(feature.properties.name); } log.Info("MapData Feature Names: {0}", String.Join(", ", names)); NLog.LogManager.Shutdown(); }
public async void GetMapDataTest() { // FIXME: Need a test base class or somewhere else generic to setup // logging!! AppLog.ConfigureLogging(); AltitudeAngelApi client = new AltitudeAngelApi(apiKey); MapData response = await client.GetMapData( 51.46227963315035, -0.9569686575500782, 51.450125805383585, -0.9857433958618458); log.Info($"xxx response: {response}"); foreach (Feature feature in response.features) { log.Info($"xxx features: {feature.properties.name}"); } }
public async void MapDataTest(ApiData apiData) { // FIXME: Need a test base class or somewhere else generic to setup // logging!! AppLog.ConfigureLogging(); log.Info($"--- Running test: {apiData.testReasoning}..."); // FIXME: move client creation to general setup method. client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("X-AA-ApiKey", apiKey); Uri requestUri = UriTools.BuildRequestUri(AltitudeAngelApi.mapDataUri, apiData.parameters); log.Info($"xxx - requestUri: {requestUri}"); HttpResponseMessage response = await client.GetAsync(requestUri); // String responseContentString = await response.Content.ReadAsStringAsync(); // log.Info($"xxx - response: {response}"); Assert.Equal(apiData.expStatusCode, response.StatusCode); }