sharee.bike-App/TestTINKLib/Fixtures/ObjectTests/Bike/TestBikesAvailableResponse.cs

70 lines
2.6 KiB
C#
Raw Permalink Normal View History

2021-07-12 21:31:46 +02:00
using Newtonsoft.Json;
using NUnit.Framework;
using TINK.Repository.Response;
namespace TestTINKLib.Fixtures.ObjectTests.Bike
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[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.IsNull(l_oBikes.bikes[231].station);
}
[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);
}
}
}