sharee.bike-App/TestShareeLib/Repository/TestCopriCallsMonkeyStore.cs

84 lines
2.5 KiB
C#
Raw Normal View History

2021-06-26 20:57:55 +02:00
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();
}
}
}
}