using System.Threading.Tasks; using MonkeyCache.FileStore; using Newtonsoft.Json; using NUnit.Framework; using TINK.Repository; using TINK.Repository.Response; namespace UITest.Fixtures.ObjectTests.Connector { [TestFixture] public class TestCopriCallsMonkeyStore { [Test] public void TestConstruct() { var bikesAvailable = JsonConvert.DeserializeObject(CopriCallsMonkeyStore.BIKESAVAILABLE); Assert.NotNull(bikesAvailable?.bikes); var bikesOccupied = JsonConvert.DeserializeObject(CopriCallsMonkeyStore.BIKESOCCUPIED); Assert.NotNull(bikesOccupied?.bikes_occupied); var stations = JsonConvert.DeserializeObject(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", null /*UI language */); 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", null /*UI language */); 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(); } } } }