mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-21 20:46:28 +02:00
Version 3.0.375
This commit is contained in:
parent
2c790239cb
commit
ca080c87c0
194 changed files with 10092 additions and 10464 deletions
|
@ -58,7 +58,7 @@ namespace TestShareeLib.Model.Bike.BluetoothLock
|
|||
new Guid(),
|
||||
"17"),
|
||||
"My Station Name").ToString(),
|
||||
Is.EqualTo("Id=MyBikeId;type=Cargo;state=Disposable"));
|
||||
Is.EqualTo("Id=MyBikeId;type=Cargo;state=Disposable;Lock id=42"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -3,6 +3,7 @@ using NUnit.Framework;
|
|||
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS.EngineNS;
|
||||
using DriveType = TINK.Model.Bikes.BikeInfoNS.DriveNS.DriveType;
|
||||
|
||||
namespace TestShareeLib.Model.BikeInfo.DriveNS
|
||||
{
|
||||
|
|
|
@ -314,6 +314,252 @@ namespace TestShareeLib.Model.Connector
|
|||
}
|
||||
}";
|
||||
|
||||
private const string BIKESAVAILABLE2 = @"{
|
||||
""lang"" : ""de"",
|
||||
""user_group"" : [
|
||||
""FR300103"",
|
||||
""FR300101""
|
||||
],
|
||||
""uri_primary"" : ""https://shareeapp-primary.copri.eu"",
|
||||
""bikes_occupied"" : {
|
||||
""160317"" : {
|
||||
""station"" : ""FR101"",
|
||||
""bike_type"" : {
|
||||
""category"" : ""cargo"",
|
||||
""wheels"" : ""2""
|
||||
},
|
||||
""rental_minute_all"" : 2666,
|
||||
""description"" : ""Lastenrad Oliver Pieper"",
|
||||
""unit_price"" : ""2.00"",
|
||||
""end_time"" : ""2023-10-29 12:03:28"",
|
||||
""total_price"" : ""0.00"",
|
||||
""K_u"" : ""[72, 41, 3, -121, -121, -40, -125, -92, -70, -78, -12, -73, 11, -31, 108, 63, -22, 28, -73, 35, 0, 0, 0, 0]"",
|
||||
""real_clock"" : ""1 day 20:26"",
|
||||
""rentalog"" : """",
|
||||
""bike"" : ""FR1011"",
|
||||
""gps"" : {
|
||||
""latitude"" : ""47.9765599546954"",
|
||||
""longitude"" : ""7.82557798549533""
|
||||
},
|
||||
""request_time"" : ""2023-10-27 15:37:16.296418+02"",
|
||||
""aa_ride"" : ""0"",
|
||||
""state"" : ""occupied"",
|
||||
""lock_state"" : ""unlocked"",
|
||||
""K_seed"" : ""[-77, 79, -81, -34, 107, -34, -100, -29, 124, 30, -50, -63, -111, 0, 22, -19]"",
|
||||
""Ilockit_ID"" : ""ISHAREIT-2200536"",
|
||||
""system"" : ""Ilockit"",
|
||||
""computed_hours"" : ""44.1"",
|
||||
""freed_time"" : ""- 00:20"",
|
||||
""bike_group"" : [
|
||||
""FR300101""
|
||||
],
|
||||
""start_time"" : ""2023-10-27 15:37:24.371987+02"",
|
||||
""rental_description"" : {
|
||||
""tarif_elements"" : {
|
||||
""4"" : [
|
||||
""Max. Gebühr"",
|
||||
""24,00 € / 24 Std""
|
||||
],
|
||||
""1"" : [
|
||||
""Mietgebühr"",
|
||||
""2,00 € / 30 Min ""
|
||||
],
|
||||
""7"" : [
|
||||
""Aktuelle Mietzeit"",
|
||||
""1 Tag 20 Std 26 Min ""
|
||||
],
|
||||
""2"" : [
|
||||
""ab 2. Tag"",
|
||||
""3,00 € / 30 Min ""
|
||||
],
|
||||
""6"" : [
|
||||
""Gratis Mietzeit"",
|
||||
""20 Min / Tag""
|
||||
]
|
||||
},
|
||||
""reserve_timerange"" : ""15"",
|
||||
""name"" : ""E-Lastenrad private"",
|
||||
""id"" : ""5533""
|
||||
},
|
||||
""discount"" : ""-100%"",
|
||||
""uri_operator"" : ""https://shareeapp-fr01.copri.eu""
|
||||
}
|
||||
},
|
||||
""bike_info_html"" : ""site/bike_info_sharee_230922.html"",
|
||||
""agb_checked"" : ""1"",
|
||||
""user_tour"" : [],
|
||||
""last_used_operator"" : {
|
||||
""operator_name"" : ""TeilRad GmbH"",
|
||||
""operator_phone"" : ""+49 761 45370097"",
|
||||
""operator_email"" : ""hotline@sharee.bike"",
|
||||
""operator_hours"" : ""Bürozeiten: Montag, Mittwoch, Freitag 9-12 Uhr""
|
||||
},
|
||||
""user_id"" : ""ohauff@posteo.de"",
|
||||
""impress_html"" : ""site/impress_1.html"",
|
||||
""authcookie"" : ""5781_f172cf59108fe53e7524c841847fee69_shoo0faiNg"",
|
||||
""faq_app_fullurl"" : ""https://sharee.bike/faq/fahrrad-nutzung"",
|
||||
""tariff_info_html"" : ""site/tarif_info_sharee_230922.html"",
|
||||
""agb_html"" : ""site/agb_sharee_2.html"",
|
||||
""response"" : ""bikes_available"",
|
||||
""bikes"" : {
|
||||
""FR1545"" : {
|
||||
""Ilockit_GUID"" : ""00000000-0000-0000-0000-e38bf9d32234"",
|
||||
""description"" : ""C2-02-00545"",
|
||||
""lock_state"" : ""locked"",
|
||||
""system"" : ""Ilockit"",
|
||||
""Ilockit_ID"" : ""ISHAREIT-2200545"",
|
||||
""state"" : ""available"",
|
||||
""aa_ride"" : ""0"",
|
||||
""smartlock_type"" : {
|
||||
""battery"" : {
|
||||
""charge_current_percent"" : ""100""
|
||||
},
|
||||
""engine"" : {
|
||||
""manufacturer"" : ""Ilockit""
|
||||
}
|
||||
},
|
||||
""bike_type"" : {
|
||||
""battery"" : {
|
||||
""charge_max_bars"" : ""5"",
|
||||
""charge_current_bars"" : ""0"",
|
||||
""charge_current_percent"" : ""0"",
|
||||
""hidden"" : ""0"",
|
||||
""backend_accessible"" : ""0""
|
||||
},
|
||||
""engine"" : {
|
||||
""manufacturer"" : ""dummy""
|
||||
},
|
||||
""category"" : ""cargo"",
|
||||
""wheels"" : ""2""
|
||||
},
|
||||
""station"" : ""FR101"",
|
||||
""uri_operator"" : ""https://shareeapp-fr01.copri.eu"",
|
||||
""gps"" : {
|
||||
""latitude"" : ""47.9767844"",
|
||||
""longitude"" : ""7.8258182""
|
||||
},
|
||||
""bike"" : ""FR1545"",
|
||||
""bike_group"" : [
|
||||
""FR300101""
|
||||
],
|
||||
""authed"" : ""1"",
|
||||
""rental_description"" : {
|
||||
""id"" : ""5533"",
|
||||
""reserve_timerange"" : ""15"",
|
||||
""name"" : ""E-Lastenrad private"",
|
||||
""tarif_type"" : ""3"",
|
||||
""tarif_elements"" : {
|
||||
""6"" : [
|
||||
""Gratis Mietzeit"",
|
||||
""20 Min / Tag""
|
||||
],
|
||||
""2"" : [
|
||||
""ab 2. Tag"",
|
||||
""3,00 € / 30 Min ""
|
||||
],
|
||||
""4"" : [
|
||||
""Max. Gebühr"",
|
||||
""24,00 € / 24 Std""
|
||||
],
|
||||
""1"" : [
|
||||
""Mietgebühr"",
|
||||
""2,00 € / 30 Min ""
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
""FR1012"" : {
|
||||
""uri_operator"" : ""https://shareeapp-fr01.copri.eu"",
|
||||
""bike"" : ""FR1012"",
|
||||
""gps"" : {
|
||||
""latitude"" : ""47.998034725897"",
|
||||
""longitude"" : ""7.78498157858849""
|
||||
},
|
||||
""bike_group"" : [
|
||||
""FR300101""
|
||||
],
|
||||
""rental_description"" : {
|
||||
""rental_info"" : {
|
||||
""1"" : [
|
||||
""Tracking"",
|
||||
""Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!""
|
||||
]
|
||||
},
|
||||
""tarif_elements"" : {
|
||||
""1"" : [
|
||||
""Mietgebühr"",
|
||||
""2,00 € / 30 Min ""
|
||||
],
|
||||
""4"" : [
|
||||
""Max. Gebühr"",
|
||||
""24,00 € / 24 Std""
|
||||
],
|
||||
""6"" : [
|
||||
""Gratis Mietzeit"",
|
||||
""20 Min / Tag""
|
||||
],
|
||||
""2"" : [
|
||||
""ab 2. Tag"",
|
||||
""3,00 € / 30 Min ""
|
||||
]
|
||||
},
|
||||
""reserve_timerange"" : ""15"",
|
||||
""name"" : ""E-Lastenrad private"",
|
||||
""id"" : ""5533"",
|
||||
""tarif_type"" : ""3""
|
||||
},
|
||||
""authed"" : ""1"",
|
||||
""description"" : ""Contributor-bike devel"",
|
||||
""Ilockit_GUID"" : ""00000000-0000-0000-0000-ef6655036de7"",
|
||||
""lock_state"" : ""locked"",
|
||||
""system"" : ""Ilockit"",
|
||||
""Ilockit_ID"" : ""ISHAREIT-2309492"",
|
||||
""state"" : ""available"",
|
||||
""bike_type"" : {
|
||||
""engine"" : {
|
||||
""manufacturer"" : ""dummy""
|
||||
},
|
||||
""battery"" : {
|
||||
""charge_current_bars"" : ""5"",
|
||||
""charge_max_bars"" : ""5"",
|
||||
""backend_accessible"" : ""0"",
|
||||
""charge_current_percent"" : ""100"",
|
||||
""hidden"" : ""0""
|
||||
},
|
||||
""category"" : ""cargo"",
|
||||
""wheels"" : ""2""
|
||||
},
|
||||
""smartlock_type"" : {
|
||||
""engine"" : {
|
||||
""manufacturer"" : ""Ilockit""
|
||||
},
|
||||
""battery"" : {
|
||||
""charge_current_percent"" : """"
|
||||
}
|
||||
},
|
||||
""aa_ride"" : ""0"",
|
||||
""station"" : ""FR103""
|
||||
},
|
||||
},
|
||||
""aowner"" : ""186"",
|
||||
""init_map"" : {
|
||||
""radius"" : ""2.9"",
|
||||
""center"" : {
|
||||
""longitude"" : ""7.825490"",
|
||||
""latitude"" : ""47.976634""
|
||||
}
|
||||
},
|
||||
""new_authcoo"" : ""0"",
|
||||
""apiserver"" : ""https://shareeapp-fr01.copri.eu"",
|
||||
""merchant_id"" : ""shoo0faiNg"",
|
||||
""privacy_html"" : ""site/privacy_sharee_2.html"",
|
||||
""response_state"" : ""OK, nothing todo"",
|
||||
""debuglevel"" : ""104"",
|
||||
""clearing_cache"" : ""0"",
|
||||
""copri_version"" : ""4.1.23.20"",
|
||||
""project_id"" : ""Freiburg""
|
||||
}";
|
||||
|
||||
private const string BIKESAVAILABLEEMPTY = @"{
|
||||
""copri_version"" : ""4.1.0.0"",
|
||||
""bikes"" : {},
|
||||
|
@ -609,5 +855,46 @@ namespace TestShareeLib.Model.Connector
|
|||
Assert.IsNull(result.Exception);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestGetBikesOperratorUri()
|
||||
{
|
||||
var server = Substitute.For<ICachedCopriServer>();
|
||||
|
||||
server.GetBikesAvailable(operatorUri: Arg.Any<Uri>()).Returns(Task.Run(() => new Result<BikesAvailableResponse>(
|
||||
typeof(CopriCallsHttps),
|
||||
JsonConvert.DeserializeObject<BikesAvailableResponse>(BIKESAVAILABLE2),
|
||||
new GeneralData())));
|
||||
|
||||
var result = await new CachedQueryLoggedIn(server, "123", "a@b", () => DateTime.Now).GetBikesAsync(new Uri("https://shareeapp-fr01.copri.eu//APIjsonserver"));
|
||||
|
||||
await server.DidNotReceive().GetBikesOccupied();
|
||||
await server.DidNotReceive().GetBikesOccupied(Arg.Any<bool>());
|
||||
server.Received().AddToCache(Arg.Any<Result<BikesAvailableResponse>>(), Arg.Any<Uri>());
|
||||
|
||||
Assert.AreEqual(3, result.Response.Count);
|
||||
Assert.AreEqual(typeof(CopriCallsHttps), result.Source);
|
||||
Assert.IsNull(result.Exception);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestGetBikesOperratorUriCache()
|
||||
{
|
||||
var server = Substitute.For<ICachedCopriServer>();
|
||||
|
||||
server.GetBikesAvailable(operatorUri: Arg.Any<Uri>()).Returns(Task.Run(() => new Result<BikesAvailableResponse>(
|
||||
typeof(CopriCallsMonkeyStore),
|
||||
JsonConvert.DeserializeObject<BikesAvailableResponse>(BIKESAVAILABLE2),
|
||||
new GeneralData())));
|
||||
|
||||
var result = await new CachedQueryLoggedIn(server, "123", "a@b", () => DateTime.Now).GetBikesAsync(new Uri("https://shareeapp-fr01.copri.eu//APIjsonserver"));
|
||||
|
||||
await server.DidNotReceive().GetBikesOccupied();
|
||||
await server.DidNotReceive().GetBikesOccupied(Arg.Any<bool>());
|
||||
server.DidNotReceive().AddToCache(Arg.Any<Result<BikesAvailableResponse>>(), Arg.Any<Uri>());
|
||||
|
||||
Assert.AreEqual(3, result.Response.Count);
|
||||
Assert.AreEqual(typeof(CopriCallsMonkeyStore), result.Source);
|
||||
Assert.IsNull(result.Exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
|||
using TINK.Model.Connector;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.Repository.Response;
|
||||
using TINK.Repository.Response.Stations;
|
||||
using TINK.Repository.Response.Stations.Station;
|
||||
using JsonConvertRethrow = TINK.Repository.Response.JsonConvertRethrow;
|
||||
|
||||
|
@ -1080,5 +1079,93 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
}").GetMaxReservationTimeSpan().TotalMinutes,
|
||||
Is.EqualTo(15));
|
||||
|
||||
[Test]
|
||||
public void TestGetOperatorUriNull()
|
||||
=> Assert.That(
|
||||
TextToTypeHelper.GetOperatorUri(stationInfo: null),
|
||||
Is.Null);
|
||||
|
||||
[Test]
|
||||
public void TestGetOperatorUriEmpty()
|
||||
=> Assert.That(
|
||||
JsonConvertRethrow.DeserializeObject<StationInfo>(@"").GetOperatorUri(),
|
||||
Is.Null);
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestGetOperatorUriNoUri()
|
||||
=> Assert.That(
|
||||
JsonConvertRethrow.DeserializeObject<StationInfo>(@"
|
||||
{
|
||||
""station"": ""FR101""
|
||||
}").GetOperatorUri(),
|
||||
Is.Null);
|
||||
|
||||
[Test]
|
||||
public void TestGetOperatorUriInvalidUrl()
|
||||
=> Assert.That(
|
||||
JsonConvertRethrow.DeserializeObject<StationInfo>(@"
|
||||
{
|
||||
""station"": ""FR101"",
|
||||
""uri_operator"": ""ThisIsNoUrl""
|
||||
}").GetOperatorUri(),
|
||||
Is.Null);
|
||||
|
||||
[Test]
|
||||
public void TestGetOperatorUri()
|
||||
=> Assert.That(
|
||||
JsonConvertRethrow.DeserializeObject<StationInfo>(@"
|
||||
{
|
||||
""station"": ""FR101"",
|
||||
""uri_operator"": ""https://shareedms-tr.copri.eu""
|
||||
}").GetOperatorUri().AbsoluteUri,
|
||||
Is.EqualTo("https://shareedms-tr.copri.eu//APIjsonserver"));
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestGetStation()
|
||||
{
|
||||
var stationInfo = JsonConvertRethrow.DeserializeObject<StationInfo>(@"{
|
||||
""station"": ""FR104"",
|
||||
""withpub"": ""1"",
|
||||
""cached"": ""1"",
|
||||
""authed"": ""1"",
|
||||
""state"": ""available"",
|
||||
""operator_data"": {
|
||||
""operator_email"": ""hotline@sharee.bike"",
|
||||
""operator_hours"": ""Bürozeiten: Montag, Mittwoch, Freitag 9-12 Uhr"",
|
||||
""operator_phone"": ""+49 761 45370097"",
|
||||
""operator_name"": ""TeilRad GmbH""
|
||||
},
|
||||
""station_type"": {
|
||||
""city"": {
|
||||
""bike_group"": ""FR300103"",
|
||||
""bike_count"": ""0""
|
||||
},
|
||||
""cargo"": {
|
||||
""bike_group"": ""FR300101"",
|
||||
""bike_count"": ""0""
|
||||
}
|
||||
},
|
||||
""uri_operator"": ""https://shareeapp-fr01.copri.eu"",
|
||||
""gps_radius"": ""50"",
|
||||
""capacity"": ""1"",
|
||||
""description"": ""fahrradspezialitäten"",
|
||||
""gps"": {
|
||||
""longitude"": ""7.837621"",
|
||||
""latitude"": ""47.989807""
|
||||
},
|
||||
""station_group"": [
|
||||
""FR300101"",
|
||||
""FR300103""
|
||||
],
|
||||
""bike_count"": ""0""
|
||||
}");
|
||||
|
||||
var station = stationInfo.GetStation();
|
||||
Assert.That(
|
||||
station.OperatorUri.AbsoluteUri,
|
||||
Is.EqualTo("https://shareeapp-fr01.copri.eu//APIjsonserver"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
using TINK.Model.Connector.Updater;
|
||||
using TINK.Repository.Response;
|
||||
using DriveType = TINK.Model.Bikes.BikeInfoNS.DriveNS.DriveType;
|
||||
|
||||
namespace TestShareeLib.Model.Connector.Updater
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue