Beispiel #1
0
        public void TestBusLive()
        {
            var mockHandler = getHandler("BusLiveResponse.json");

            var client = new TransportApiClient(ApiCredentials.appId, ApiCredentials.appKey, mockHandler);

            var response = client.BusLive("490000077D").Result;

            Assert.AreEqual(4, response.Departures.Count);
        }
        private async Task getDepartures(BusStopParameter parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            using (var client = new TransportApiClient(ApiCredentials.appId, ApiCredentials.appKey))
            {
                if (!(bool)UseLiveData)
                {
                    var response = await client.BusTimetable(parameters.AtcoCode, DateTime.Now, true);

                    if (response == null)
                    {
                        CommandBarTitle = $"Could not retrieve departures!";
                    }
                    else
                    {
                        CommandBarTitle = $"Next buses from {parameters.StopName}";
                        populateTimetableDepartures(response);
                    }
                }
                else
                {
                    var response = await client.BusLive(parameters.AtcoCode, true, nextBuses : true);

                    if (response == null)
                    {
                        CommandBarTitle = $"Could not retrieve departures!";
                    }
                    else
                    {
                        CommandBarTitle = $"Next buses from {parameters.StopName}";
                        populateLiveDepartures(response);
                    }
                }
            }
        }