public void RealtimeDeparturesAsyncTest() { var fakekey = "fakekey"; var mockedHttpRequest = HttpRequestMocker.GetMockedRequesterFor(new Uri( "https://api.sl.se/api2/realtimedepartures.json/?SiteId=9305&TimeWindow=2&key=" + fakekey), GetTestResponse()); var t = new RealtimeInformationClient(new HttpClient("https://api.sl.se/", mockedHttpRequest, new UrlHelper())) { ApiToken = fakekey }; var responseAsync = t.RealtimeDeparturesAsync(new RealtimeDeparturesRequest { SiteId = 9305, TimeWindow = 2 }); responseAsync.Wait(); var result = responseAsync.Result; var firstMetro = result.ResponseData.Metros.FirstOrDefault(); var firstBus = result.ResponseData.Buses.FirstOrDefault(); Assert.IsTrue(firstMetro != null); Assert.IsTrue(firstBus != null); Assert.IsTrue(result.StatusCode == StatusCode.Ok); Assert.IsTrue(result.ResponseData.Buses.Count() == 1); Assert.IsTrue(!result.ResponseData.Ships.Any()); Assert.IsTrue(result.ResponseData.Metros.Count() == 6); Assert.IsTrue(firstMetro.DisplayTime == "5 min"); Assert.IsTrue(firstMetro.TransportModeEnum == TransportModeEnum.Metro); Assert.IsTrue(firstBus.TransportModeEnum == TransportModeEnum.Bus); }
public void RealtimeDeparturesTestSuccess() { var token = EnvironmentHelper.GetEnvironmentVariable("RealtimeInformationClientApiToken"); var client = new RealtimeInformationClient(token) { GzipEnabled = true, }; var result = client.RealtimeDepartures(new RealtimeDeparturesRequest()); Assert.IsTrue(result.ResponseData.LatestUpdate.Year > 2014); }