Exemplo n.º 1
0
        public async Task GetShows_ReturnsNoShowsWhenNothingHasBeenFound()
        {
            IKinoheldClient client = new KinoheldClient();
            var             shows  = await client.GetShows(999999);

            Assert.AreEqual(0, shows.Count());
        }
Exemplo n.º 2
0
        public async Task GetShows_ReturnsSomeShows()
        {
            IKinoheldClient client = new KinoheldClient();
            var             shows  = await client.GetShows(2127);

            Assert.AreNotEqual(0, shows.Count());
        }
Exemplo n.º 3
0
        public async Task GetCinemas_ReturnsNoCinemasWhenNothingHasBeenFound()
        {
            IKinoheldClient client  = new KinoheldClient();
            var             cinemas = await client.GetCinemas("DummyNotValid");

            Assert.AreEqual(0, cinemas.Count());
        }
Exemplo n.º 4
0
        private async Task <List <Show> > GetShowsFromApi(Cinema cinema, DateTime showDate)
        {
            await m_semaphoreSlim.WaitAsync();

            try
            {
                var client = new KinoheldClient();

                m_logger.LogDebug("Retrieving shows for selected cinema");
                var cts   = new CancellationTokenSource(TimeoutApiCallsMs);
                var shows = (await client.GetShows(cinema.Id, showDate, cancellationToken: cts.Token).ConfigureAwait(false)).ToList();
                m_logger.LogDebug($"{shows.Count} shows were found.");

                return(shows);
            }
            catch (Exception e)
            {
                m_logger.LogError(e, "Error retrieving shows for selected cinema");
                throw;
            }
            finally
            {
                m_semaphoreSlim.Release();
            }
        }
Exemplo n.º 5
0
        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 GetShows_ReturnEmptyListWhenNoShowsWereFound()
        {
            IKinoheldClient client = new KinoheldClient(m_kinoheldApiClientMock.Object, m_kinoheldJsonWorkerMock.Object);
            var             shows  = await client.GetShows(1);

            Assert.NotNull(shows);
            Assert.AreEqual(0, shows.Count());
        }
        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 void KinoheldClient_DoesNotAllowNullJsonWorker()
 {
     Assert.Throws <ArgumentNullException>(
         () =>
     {
         IKinoheldClient client = new KinoheldClient(new KinoheldApiClient(), null);
     });
 }
Exemplo n.º 9
0
        public async Task GetCities_ReturnsNoCitiesWhenNothingHasBeenFound()
        {
            IKinoheldClient client = new KinoheldClient();
            var             cities = await client.GetCities("999999");

            Assert.AreEqual(0, cities.Cities.Count);
            Assert.AreEqual(0, cities.PostalCodes.Count);
        }
Exemplo n.º 10
0
        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 GetCities_ReturnEmptyResultWhenNoCitiesWereFound()
        {
            IKinoheldClient client = new KinoheldClient(m_kinoheldApiClientMock.Object, m_kinoheldJsonWorkerMock.Object);
            var             result = await client.GetCities("aurick");

            Assert.NotNull(result);
            Assert.AreEqual(0, result.Cities.Count);
            Assert.AreEqual(0, result.PostalCodes.Count);
        }
Exemplo n.º 12
0
        public async Task GetCities_ReturnsAurichWithAuric()
        {
            IKinoheldClient client = new KinoheldClient();
            var             cities = await client.GetCities("auric");

            Assert.AreEqual(1, cities.Cities.Count);
            Assert.AreEqual(0, cities.PostalCodes.Count);
            Assert.AreEqual("Aurich", cities.Cities[0].Name);
        }
Exemplo n.º 13
0
        public async Task GetShows_ReturnsSomeShowsUsingADynamicNameQuery()
        {
            IKinoheldClient client       = new KinoheldClient();
            var             dynamicQuery = GetShowsDynamicQuery.Name;
            var             shows        = await client.GetShows(2127, dynamicQuery : dynamicQuery);

            Assert.AreNotEqual(0, shows.Count());
            Assert.True(shows.All(p => p.Flags == null && p.Beginning == null && p.DetailUrl == null && p.MovieInfo == null), "The dynamic name query gives too much info");
            Assert.True(!shows.Any(p => string.IsNullOrEmpty(p.Name)), "The dynamic name query gives too less info");
        }
Exemplo n.º 14
0
        public async Task GetShows_ReturnsSomeShowsOtherDateThanToday()
        {
            var tommorow = DateTime.Now.AddDays(1).Date;

            IKinoheldClient client = new KinoheldClient();
            var             shows  = await client.GetShows(2127, tommorow);

            Assert.AreNotEqual(0, shows.Count());
            Assert.True(shows.All(p => p.Beginning.GetDateTime().Date == tommorow));
        }
Exemplo n.º 15
0
        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");
        }
Exemplo n.º 16
0
        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);
            });
        }
Exemplo n.º 17
0
        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();
            }
        }