mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-12-23 15:46:29 +01:00
68 lines
2.6 KiB
C#
68 lines
2.6 KiB
C#
using Newtonsoft.Json;
|
|
using NUnit.Framework;
|
|
using TINK.Repository.Response;
|
|
|
|
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"",
|
|
""bike_group"" : [ ""Konrad"" ],
|
|
""station"" : """",
|
|
""state"" : ""available"",
|
|
""gps"" : { ""latitude"": ""9.1594501"", ""longitude"": ""47.6749928"" }
|
|
}
|
|
},
|
|
""copri_version"" : ""4.1.0.0"",
|
|
""authcookie"" : """",
|
|
""response_state"" : ""OK""
|
|
}
|
|
");
|
|
|
|
Assert.That(
|
|
l_oBikes.bikes["231"].station,
|
|
Is.Empty);
|
|
}
|
|
|
|
[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"",
|
|
""bike_group"" : [ ""Konrad"" ],
|
|
""state"" : ""available"",
|
|
""gps"" : { ""latitude"": ""9.1594501"", ""longitude"": ""47.6749928"" }
|
|
}
|
|
},
|
|
""copri_version"" : ""4.1.0.0"",
|
|
""authcookie"" : """",
|
|
""response_state"" : ""OK""
|
|
}
|
|
");
|
|
|
|
Assert.IsNull(l_oBikes.bikes["231"].station);
|
|
|
|
}
|
|
}
|
|
}
|