public async Task GetCinemas_ReturnsNoCinemasWhenNothingHasBeenFound() { IKinoheldClient client = new KinoheldClient(); var cinemas = await client.GetCinemas("DummyNotValid"); Assert.AreEqual(0, cinemas.Count()); }
public async Task GetCinemas_ReturnsAutokinoAurichWhenSearchtermIsAutokino() { IKinoheldClient client = new KinoheldClient(); var cinemas = await client.GetCinemas("aurich", "autokino"); Assert.AreNotEqual(0, cinemas.Count()); Assert.True(cinemas.Any(p => p.Name == "Autokino Aurich-Tannenhausen"), "Could not find Autokino Aurich-Tannenhausen in the response list."); }
public async Task GetCinemas_ReturnsSomeCinemasInAurich() { IKinoheldClient client = new KinoheldClient(); var cinemas = await client.GetCinemas("aurich"); Assert.AreNotEqual(0, cinemas.Count()); Assert.True(cinemas.Any(p => p.Name == "Kino Aurich"), "Could not find Kino Aurich in the response list."); }
public async Task GetCinemas_ReturnEmptyListWhenNoCinemasWereFound() { IKinoheldClient client = new KinoheldClient(m_kinoheldApiClientMock.Object, m_kinoheldJsonWorkerMock.Object); var cinemas = await client.GetCinemas("aurich"); Assert.NotNull(cinemas); Assert.AreEqual(0, cinemas.Count()); }
public async Task GetCinemas_ReturnsSomeCinemasInAurichUsingADynmamicIdNameQuery() { IKinoheldClient client = new KinoheldClient(); var dynamicQuery = GetCinemasDynamicQuery.Id | GetCinemasDynamicQuery.Name; var cinemas = await client.GetCinemas("aurich", dynamicQuery : dynamicQuery); Assert.AreNotEqual(0, cinemas.Count()); Assert.True(cinemas.Any(p => p.Name == "Kino Aurich"), "Could not find Kino Aurich in the response list."); Assert.True(cinemas.All(p => p.City == null && string.IsNullOrEmpty(p.Street)), "The dynamic id / name query gives too much info"); Assert.True(!cinemas.Any(p => string.IsNullOrEmpty(p.Name) || p.Id <= 0), "The dynamic id / name query gives too less info"); }
public void GetCinemas_ThrowsOnCancel() { CancellationTokenSource cts = new CancellationTokenSource(); cts.Cancel(); IKinoheldClient client = new KinoheldClient(); Assert.ThrowsAsync <TaskCanceledException>(async() => { var o = await client.GetCinemas("aurich", cancellationToken: cts.Token); }); }
private async Task <List <Cinema> > GetCinemasFromApi(string city) { await m_semaphoreSlim.WaitAsync(); try { m_logger.LogDebug("Retrieving cinemas near selected city"); var cts = new CancellationTokenSource(TimeoutApiCallsMs); var client = new KinoheldClient(); var cinemas = await client.GetCinemas(city, distance : MaxDistanceCinemaSearch, limit : LimitCinemaSearch, cancellationToken : cts.Token).ConfigureAwait(false); return(cinemas.ToList()); } catch (Exception e) { m_logger.LogError(e, "Error retrieving shows for selected cinema"); throw; } finally { m_semaphoreSlim.Release(); } }