Esempio n. 1
0
        public async Task GetShows_ReturnsSomeShows()
        {
            IKinoheldClient client = new KinoheldClient();
            var             shows  = await client.GetShows(2127);

            Assert.AreNotEqual(0, shows.Count());
        }
Esempio n. 2
0
        public async Task GetShows_ReturnsNoShowsWhenNothingHasBeenFound()
        {
            IKinoheldClient client = new KinoheldClient();
            var             shows  = await client.GetShows(999999);

            Assert.AreEqual(0, shows.Count());
        }
Esempio n. 3
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();
            }
        }
        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());
        }
Esempio n. 5
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");
        }
Esempio n. 6
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));
        }
Esempio n. 7
0
        public void GetShows_ThrowsOnCancel()
        {
            var cts = new CancellationTokenSource();

            cts.Cancel();

            IKinoheldClient client = new KinoheldClient();

            Assert.ThrowsAsync <TaskCanceledException>(async() =>
            {
                var o = await client.GetShows(1, cancellationToken: cts.Token);
            });
        }