public void NearbystopsSuccessTest()
 {
     var token = EnvironmentHelper.GetEnvironmentVariable("NearbyStopsClientApiToken");
     var client = new NearbyStopsClient(token)
     {
         GzipEnabled = true,
         ApiToken = token
     };
     try
     {
         var stopLocations = client.Nearbystops(new NearbyStopsRequest
         {
             MaxResults = 10,
             OriginCoordLong = 17.998996D,
             OriginCoordLat = 59.358675D
         });
         var first = stopLocations.LocationList.StopLocation.FirstOrDefault();
         Assert.IsTrue(first != null);
         Assert.IsTrue(first.Name.ToLower().Contains("solna"));
     }
     catch (HttpRequestException ex)
     {
         Assert.Fail(ex.Message);
     }
 }
Esempio n. 2
0
 public void NearbyStopsErrorTest()
 {
     var fakekey = "fakekey";
     var mockedHttpRequest = HttpRequestMocker.GetMockedRequesterFor(new Uri(
                     "https://api.sl.se/api2/nearbystops.json/?originCoordLat=59.365602&originCoordLong=17.998137&key=" + fakekey), GetNearbyStationsErrorDataForTest());
     var t = new NearbyStopsClient(new HttpClient("https://api.sl.se/", mockedHttpRequest, new UrlHelper())
     {
         ApiToken = fakekey
     });
     var result = t.Nearbystops(new NearbyStopsRequest
     {
         OriginCoordLat = 59.365602,
         OriginCoordLong = 17.998137
     });
     Assert.IsTrue(result.LocationList.ErrorCode == ErrorCode.R0002);
     Assert.IsTrue(result.LocationList.ErrorText == "Ogiltiga eller saknade parametrar");
 }
Esempio n. 3
0
 public void NearbystopsTest()
 {
     var fakekey = "fakekey";
     var mockedHttpRequest = HttpRequestMocker.GetMockedRequesterFor(new Uri(
                     "https://api.sl.se/api2/nearbystops.json/?originCoordLat=59.365602&originCoordLong=17.998137&key=" + fakekey), GetNearbyStationDataForTest());
     var t = new NearbyStopsClient(new HttpClient("https://api.sl.se/", mockedHttpRequest, new UrlHelper())
     {
         ApiToken = fakekey
     });
     var result = t.Nearbystops(new NearbyStopsRequest
     {
         OriginCoordLat = 59.365602,
         OriginCoordLong = 17.998137
     });
     Assert.IsTrue(result.LocationList.StopLocation[0].Idx == 1);
     Assert.IsTrue(result.LocationList.StopLocation[0].Name == "Trappgränd (Solna)");
     Assert.IsTrue(result.LocationList.StopLocation[0].Id == "300103467");
     Assert.IsTrue(result.LocationList.StopLocation[0].SiteId == "03467");
     Assert.IsTrue(Math.Abs(result.LocationList.StopLocation[0].Lat - 59.365571) < 0.0001);
 }