Code updated to 3.0.238

This commit is contained in:
Oliver Hauff 2021-06-26 20:57:55 +02:00
parent 3302d80678
commit 9c6a1fa92b
257 changed files with 7763 additions and 2861 deletions

View file

@ -1,6 +1,6 @@
using Newtonsoft.Json;
using NUnit.Framework;
using TINK.Model.Repository.Response;
using TINK.Repository.Response;
namespace TestTINKLib.Fixtures.ObjectTests.Bike
{
@ -20,19 +20,21 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
""bike"" : ""231"",
""description"" : ""Stadtrad"",
""system"" : ""BC"",
""bike_group"" : ""Konrad"",
""bike_group"" : [ ""Konrad"" ],
""station"" : """",
""state"" : ""available"",
""gps"" : ""9.1594501, 47.6749928""
""gps"" : { ""latitude"": ""9.1594501"", ""longitude"": ""47.6749928"" }
}
},
""copri_version"" : ""3.0.0.0"",
""copri_version"" : ""4.1.0.0"",
""authcookie"" : """",
""response_state"" : ""OK""
}
");
Assert.IsNull(l_oBikes.bikes[231].station);
Assert.That(
l_oBikes.bikes["231"].station,
Is.Empty);
}
[Test]
@ -48,18 +50,18 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
""bike"" : ""231"",
""description"" : ""Stadtrad"",
""system"" : ""BC"",
""bike_group"" : ""Konrad"",
""bike_group"" : [ ""Konrad"" ],
""state"" : ""available"",
""gps"" : ""9.1594501, 47.6749928""
""gps"" : { ""latitude"": ""9.1594501"", ""longitude"": ""47.6749928"" }
}
},
""copri_version"" : ""3.0.0.0"",
""copri_version"" : ""4.1.0.0"",
""authcookie"" : """",
""response_state"" : ""OK""
}
");
Assert.IsNull(l_oBikes.bikes[231].station);
Assert.IsNull(l_oBikes.bikes["231"].station);
}
}

View file

@ -11,7 +11,7 @@ namespace TestShareeLib.Model.Repository.Response
public void TestDeserializeObject()
{
Assert.That(
() => JsonConvert.DeserializeObject<TariffDescription>(
() => JsonConvertRethrow.DeserializeObject<TariffDescription>(
@"{
""eur_per_hour"" : ""10.00"",
""abo_eur_per_month"" : ""920.00"",

View file

@ -9,7 +9,7 @@ namespace TestShareeLib.Repository.Response
[Test]
public void TestDeserialize()
{
var tariffDescription = JsonConvert.DeserializeObject<TariffDescription>(
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
@"{
""eur_per_hour"" : ""10.00"",
""abo_eur_per_month"" : ""920.00"",
@ -45,7 +45,7 @@ namespace TestShareeLib.Repository.Response
[Test]
public void TestDeserialize_Missing()
{
var tariffDescription = JsonConvert.DeserializeObject<TariffDescription>(
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
@"{
""number"" : ""5494"",
""name"" : ""Tester Basic""
@ -78,7 +78,7 @@ namespace TestShareeLib.Repository.Response
[Test]
public void TestDeserialize_NewElement()
{
var tariffDescription = JsonConvert.DeserializeObject<TariffDescription>(
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
@"{
""number"" : ""5494"",
""name"" : ""Tester Basic"",

View file

@ -0,0 +1,17 @@
using NUnit.Framework;
namespace UITest.Fixtures.Connector
{
[TestFixture]
public class TestCopriCallsHttps
{
public const string CATEGORY_REQUIRESCOPRI = "RequiresCOPRI";
public const string CATEGORY_USESLIVESERVER = "RequiresCOPRI.Live";
public const string CATEGORY_USESDEVELSERVER = "RequiresCOPRI.Devel";
public const string TESTAGENT = "TestShareeLib";
}
}

View file

@ -0,0 +1,83 @@
using MonkeyCache.FileStore;
using Newtonsoft.Json;
using NUnit.Framework;
using System.Threading.Tasks;
using TINK.Repository;
using TINK.Repository.Response;
namespace UITest.Fixtures.ObjectTests.Connector
{
[TestFixture]
public class TestCopriCallsMonkeyStore
{
[Test]
public void TestConstruct()
{
var bikesAvailable = JsonConvert.DeserializeObject<BikesAvailableResponse>(CopriCallsMonkeyStore.BIKESAVAILABLE);
Assert.NotNull(bikesAvailable?.bikes);
var bikesOccupied = JsonConvert.DeserializeObject<BikesReservedOccupiedResponse>(CopriCallsMonkeyStore.BIKESOCCUPIED);
Assert.NotNull(bikesOccupied?.bikes_occupied);
var stations = JsonConvert.DeserializeObject<StationsAllResponse>(CopriCallsMonkeyStore.STATIONSALL);
Assert.NotNull(stations?.stations);
}
[Test]
public async Task TestGetStations()
{
if (string.IsNullOrEmpty(Barrel.ApplicationId))
{
Barrel.ApplicationId = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
}
try
{
var cache = new CopriCallsMonkeyStore("123456789");
Assert.AreEqual(0, (await cache.GetStationsAsync()).stations.Count);
}
finally
{
Barrel.Current.EmptyAll();
}
}
[Test]
public async Task TestGetBikesAvailable()
{
if (string.IsNullOrEmpty(Barrel.ApplicationId))
{
Barrel.ApplicationId = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
}
try
{
var cache = new CopriCallsMonkeyStore("123456789");
Assert.AreEqual(0, (await cache.GetBikesAvailableAsync()).bikes.Count);
}
finally
{
Barrel.Current.EmptyAll();
}
}
[Test]
public async Task TestGetBikesOccupied()
{
if (string.IsNullOrEmpty(Barrel.ApplicationId))
{
Barrel.ApplicationId = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
}
try
{
var cache = new CopriCallsMonkeyStore("123456789", "abc");
Assert.AreEqual(0, (await cache.GetBikesOccupiedAsync()).bikes_occupied.Count);
}
finally
{
Barrel.Current.EmptyAll();
}
}
}
}

View file

@ -0,0 +1,86 @@
using Newtonsoft.Json;
using NUnit.Framework;
using TINK.Repository.Response;
using TINK.Repository;
namespace TestShareeLib.Repository
{
[TestFixture]
public class TestCopriCallsStatic
{
[Test]
public void TestDeserializeResponse_Factory_SupportedVersion()
{
var response = @"
{
""shareejson"" :
{
""copri_version"" : ""4.1.5.7""
}
}";
Assert.That(
response.DeserializeResponse(version => new ResponseBase()).copri_version,
Is.EqualTo("4.1.5.7"));
}
[Test]
public void TestDeserializeResponse_Factory_UnspportedVersion()
{
// Future version
var response = @"
{
""shareejson"" :
{
""copri_version"" : ""4.2.5.7""
}
}";
var factoryObject = JsonConvert.DeserializeObject<ResponseContainer<ResponseBase>>(
@"{
""shareejson"" :
{
""copri_version"" : ""9.9.9.9""
}
}");
Assert.That(
response.DeserializeResponse(version => factoryObject).shareejson.copri_version,
Is.EqualTo("9.9.9.9"));
}
[Test]
public void TestDeserializeResponse_Exception_SupportedVersion()
{
// Future version
var response = @"
{
""shareejson"" :
{
""copri_version"" : ""4.1.5.7""
}
}";
Assert.That(
response.DeserializeResponse<ResponseBase>(version => new System.Exception("hello")).copri_version,
Is.EqualTo("4.1.5.7"),
"No exception must be thrown because version 4.1.x is supported.");
}
[Test]
public void TestDeserializeResponse_Exception_UnspportedVersion()
{
var response = @"
{
""shareejson"" :
{
""copri_version"" : ""4.2.5.7""
}
}";
Assert.That(
() => response.DeserializeResponse<ResponseBase>(version => new System.Exception("Ho")).copri_version,
Throws.InstanceOf<System.Exception>());
}
}
}