2021-05-13 20:09:46 +02:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using NUnit.Framework;
|
2021-06-26 20:57:55 +02:00
|
|
|
|
using TINK.Repository.Response;
|
2021-05-13 20:09:46 +02:00
|
|
|
|
|
|
|
|
|
namespace TestTINKLib.Fixtures.ObjectTests.Bike
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class TestBikesAvailableResponse
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDeserializeStationEmpty()
|
|
|
|
|
{
|
|
|
|
|
// Response for bike 231 is a real world answer.
|
|
|
|
|
var l_oBikes = JsonConvert.DeserializeObject<BikesAvailableResponse>(@"
|
|
|
|
|
{
|
|
|
|
|
""apiserver"" : ""https://app.tink-konstanz.de"",
|
|
|
|
|
""response"" : ""bikes_available"",
|
|
|
|
|
""bikes"" : {
|
|
|
|
|
""231"" : {
|
|
|
|
|
""bike"" : ""231"",
|
|
|
|
|
""description"" : ""Stadtrad"",
|
|
|
|
|
""system"" : ""BC"",
|
2021-06-26 20:57:55 +02:00
|
|
|
|
""bike_group"" : [ ""Konrad"" ],
|
2021-05-13 20:09:46 +02:00
|
|
|
|
""station"" : """",
|
|
|
|
|
""state"" : ""available"",
|
2021-06-26 20:57:55 +02:00
|
|
|
|
""gps"" : { ""latitude"": ""9.1594501"", ""longitude"": ""47.6749928"" }
|
2021-05-13 20:09:46 +02:00
|
|
|
|
}
|
|
|
|
|
},
|
2021-06-26 20:57:55 +02:00
|
|
|
|
""copri_version"" : ""4.1.0.0"",
|
2021-05-13 20:09:46 +02:00
|
|
|
|
""authcookie"" : """",
|
|
|
|
|
""response_state"" : ""OK""
|
|
|
|
|
}
|
|
|
|
|
");
|
|
|
|
|
|
2021-06-26 20:57:55 +02:00
|
|
|
|
Assert.That(
|
|
|
|
|
l_oBikes.bikes["231"].station,
|
|
|
|
|
Is.Empty);
|
2021-05-13 20:09:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDeserializeStationInfoMissing()
|
|
|
|
|
{
|
|
|
|
|
// Response for bike 231 might not be real world answer.
|
|
|
|
|
var l_oBikes = JsonConvert.DeserializeObject<BikesAvailableResponse>(@"
|
|
|
|
|
{
|
|
|
|
|
""apiserver"" : ""https://app.tink-konstanz.de"",
|
|
|
|
|
""response"" : ""bikes_available"",
|
|
|
|
|
""bikes"" : {
|
|
|
|
|
""231"" : {
|
|
|
|
|
""bike"" : ""231"",
|
|
|
|
|
""description"" : ""Stadtrad"",
|
|
|
|
|
""system"" : ""BC"",
|
2021-06-26 20:57:55 +02:00
|
|
|
|
""bike_group"" : [ ""Konrad"" ],
|
2021-05-13 20:09:46 +02:00
|
|
|
|
""state"" : ""available"",
|
2021-06-26 20:57:55 +02:00
|
|
|
|
""gps"" : { ""latitude"": ""9.1594501"", ""longitude"": ""47.6749928"" }
|
2021-05-13 20:09:46 +02:00
|
|
|
|
}
|
|
|
|
|
},
|
2021-06-26 20:57:55 +02:00
|
|
|
|
""copri_version"" : ""4.1.0.0"",
|
2021-05-13 20:09:46 +02:00
|
|
|
|
""authcookie"" : """",
|
|
|
|
|
""response_state"" : ""OK""
|
|
|
|
|
}
|
|
|
|
|
");
|
|
|
|
|
|
2021-06-26 20:57:55 +02:00
|
|
|
|
Assert.IsNull(l_oBikes.bikes["231"].station);
|
2021-05-13 20:09:46 +02:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|