sharee.bike-App/TestShareeLib/Repository/TestCopriCallsMonkeyStore.cs
2021-07-20 23:06:09 +02:00

84 lines
2.6 KiB
C#

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<StationsAvailableResponse>(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();
}
}
}
}