2022-08-30 15:42:25 +02:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using MonkeyCache.FileStore;
|
2021-06-26 20:57:55 +02:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using TINK.Repository;
|
|
|
|
|
using TINK.Repository.Response;
|
|
|
|
|
|
|
|
|
|
namespace UITest.Fixtures.ObjectTests.Connector
|
|
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[TestFixture]
|
|
|
|
|
public class TestCopriCallsMonkeyStore
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestConstruct()
|
|
|
|
|
{
|
|
|
|
|
var bikesAvailable = JsonConvert.DeserializeObject<BikesAvailableResponse>(CopriCallsMonkeyStore.BIKESAVAILABLE);
|
|
|
|
|
Assert.NotNull(bikesAvailable?.bikes);
|
2021-06-26 20:57:55 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
var bikesOccupied = JsonConvert.DeserializeObject<BikesReservedOccupiedResponse>(CopriCallsMonkeyStore.BIKESOCCUPIED);
|
|
|
|
|
Assert.NotNull(bikesOccupied?.bikes_occupied);
|
2021-06-26 20:57:55 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
var stations = JsonConvert.DeserializeObject<StationsAvailableResponse>(CopriCallsMonkeyStore.STATIONSALL);
|
|
|
|
|
Assert.NotNull(stations?.stations);
|
|
|
|
|
}
|
2021-06-26 20:57:55 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public async Task TestGetStations()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(Barrel.ApplicationId))
|
|
|
|
|
{
|
|
|
|
|
Barrel.ApplicationId = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
|
|
|
|
|
}
|
2021-06-26 20:57:55 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var cache = new CopriCallsMonkeyStore("123456789", null /*UI language */);
|
|
|
|
|
Assert.AreEqual(0, (await cache.GetStationsAsync()).stations.Count);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Barrel.Current.EmptyAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-26 20:57:55 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public async Task TestGetBikesAvailable()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(Barrel.ApplicationId))
|
|
|
|
|
{
|
|
|
|
|
Barrel.ApplicationId = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
|
|
|
|
|
}
|
2021-06-26 20:57:55 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var cache = new CopriCallsMonkeyStore("123456789", null /*UI language */);
|
|
|
|
|
Assert.AreEqual(0, (await cache.GetBikesAvailableAsync()).bikes.Count);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Barrel.Current.EmptyAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-26 20:57:55 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public async Task TestGetBikesOccupied()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(Barrel.ApplicationId))
|
|
|
|
|
{
|
|
|
|
|
Barrel.ApplicationId = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
|
|
|
|
|
}
|
2021-06-26 20:57:55 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var cache = new CopriCallsMonkeyStore("123456789", "abc");
|
|
|
|
|
Assert.AreEqual(0, (await cache.GetBikesOccupiedAsync()).bikes_occupied.Count);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Barrel.Current.EmptyAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-26 20:57:55 +02:00
|
|
|
|
}
|