// ReSharper disable once InconsistentNaming
        public async Task GetFullShowsByTheTvDbIdsAsync_should_return_full_shows_by_ids()
        {
            using (var context = CreateContext())
            {
                await SeedGenresAsync(context);

                var repo = new ShowsRepository(context);

                int[] ids = {
                    1002,
                    1003,
                    1004
                };

                var shows = await repo.GetFullShowsByTheTvDbIdsAsync(ids);

                Assert.Equal(ids.Length, shows.Length);

                for (int i = 0; i < ids.Length; i++)
                {
                    Assert.Equal(ids[i], shows[i].TheTvDbId);

                    AssertIsFull(shows[i]);
                }
            }
        }
        private TicketService CreateSearchService()
        {
            var options = new DbContextOptionsBuilder <BookMyTicketDBContext>()
                          .UseInMemoryDatabase(nameof(SearchServiceTest), new InMemoryDatabaseRoot())
                          .ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning))
                          .Options;
            var dbContext = new BookMyTicketDBContext(options);

            var cityRepository          = new CitiesRepository(dbContext);
            var movieRepository         = new MoviesRepository(dbContext);
            var cinemaRepository        = new CinemasRepository(dbContext);
            var showsRepository         = new ShowsRepository(dbContext);
            var cinemaSeatingRepository = new CinemaSeatingRepository(dbContext);
            var ticketsRepository       = new TicketsRepository(dbContext);
            var reservationsRepository  = new ReservationsRepository(dbContext);
            var configuration           = new MapperConfiguration(cfg => cfg.AddProfile(new MappingProfile()));
            var clientContext           = new ClientContext()
            {
                UserInfo = new Models.UserProfile()
                {
                    ID = 1
                }
            };
            var mapper = new Mapper(configuration);

            MockDB(dbContext);
            var searchService = new SearchService(cityRepository, movieRepository, cinemaRepository, showsRepository, cinemaSeatingRepository, ticketsRepository, reservationsRepository, mapper);

            return(new TicketService(showsRepository, ticketsRepository, reservationsRepository, clientContext, searchService, mapper, dbContext));
        }
Example #3
0
        public async Task ListShowsByWeekWhenGetTheatreWeek()
        {
            //Arrange
            var context = TheatreContextInit.InitializeContextInMemoryDb();

            context.Shows.AddRange(
                new List <Show>()
            {
                new Show()
                {
                    Name      = "Hamlet vs Hamlet",
                    TimeSlots = new List <TimeSlot>()
                    {
                        new TimeSlot()
                        {
                            Start = Convert.ToDateTime("31-05-2018 20:00", CultureInfo.CurrentCulture),
                            End   = Convert.ToDateTime("31-05-2018 22:00", CultureInfo.CurrentCulture)
                        },

                        new TimeSlot()
                        {
                            Start = Convert.ToDateTime("02-06-2018 20:00", CultureInfo.CurrentCulture),
                            End   = Convert.ToDateTime("02-06-2018 22:00", CultureInfo.CurrentCulture)
                        },
                        new TimeSlot()
                        {
                            Start = Convert.ToDateTime("08-06-2018 20:00", CultureInfo.CurrentCulture),
                            End   = Convert.ToDateTime("08-06-2018 22:00", CultureInfo.CurrentCulture)
                        }
                    }
                },
                new Show()
                {
                    Name      = "Branden",
                    TimeSlots = new List <TimeSlot>()
                    {
                        new TimeSlot()
                        {
                            Start = Convert.ToDateTime("01-06-2018 20:00", CultureInfo.CurrentCulture),
                            End   = Convert.ToDateTime("01-06-2018 22:00", CultureInfo.CurrentCulture)
                        },
                        new TimeSlot()
                        {
                            Start = Convert.ToDateTime("15-06-2018 20:00", CultureInfo.CurrentCulture),
                            End   = Convert.ToDateTime("15-06-2018 22:00", CultureInfo.CurrentCulture)
                        }
                    }
                }
            });
            await context.SaveChangesAsync();

            var showsRepository = new ShowsRepository(context);
            var shows           = new Controllers.OnStageController(showsRepository);
            //Act
            var listShows = await shows.GetCalendarAsync();

            //Assert
            Assert.True(listShows.Any());
            Assert.True(listShows.First().Shows.Any());
        }
        // ReSharper disable once InconsistentNaming
        public async Task GetFullShowById_should_return_null_if_the_id_does_not_exists()
        {
            using (var context = CreateContext())
            {
                await SeedGenresAsync(context);

                var repo = new ShowsRepository(context);

                var show = await repo.GetFullShowByIdAsync(10000);

                Assert.Null(show);
            }
        }
Example #5
0
        public static bool UpdateShow(int id, string name, int price, string description)
        {
            Show currentShow = ShowsRepository.GetShowById(id);

            if (currentShow != null)
            {
                currentShow.Name        = name;
                currentShow.Price       = price;
                currentShow.Description = description;

                return(ShowsRepository.UpdateShow(currentShow));
            }

            return(false);
        }
        // ReSharper disable once InconsistentNaming
        public async Task GetFullShowById_should_return_full_show_by_id()
        {
            using (var context = CreateContext())
            {
                await SeedGenresAsync(context);

                var repo = new ShowsRepository(context);

                var show = await repo.GetFullShowByIdAsync(2);

                Assert.Equal("Show2", show.Name);

                AssertIsFull(show);
            }
        }
Example #7
0
        private SearchService CreateSearchService()
        {
            var options = new DbContextOptionsBuilder <BookMyTicketDBContext>()
                          .UseInMemoryDatabase(nameof(SearchServiceTest), new InMemoryDatabaseRoot())
                          .Options;
            var dbContext = new BookMyTicketDBContext(options);

            var cityRepository          = new CitiesRepository(dbContext);
            var movieRepository         = new MoviesRepository(dbContext);
            var cinemaRepository        = new CinemasRepository(dbContext);
            var showsRepository         = new ShowsRepository(dbContext);
            var cinemaSeatingRepository = new CinemaSeatingRepository(dbContext);
            var ticketsRepository       = new TicketsRepository(dbContext);
            var reservationsRepository  = new ReservationsRepository(dbContext);
            var productProfile          = new MappingProfile();
            var configuration           = new MapperConfiguration(cfg => cfg.AddProfile(productProfile));
            var mapper = new Mapper(configuration);

            MockDB(dbContext);
            return(new SearchService(cityRepository, movieRepository, cinemaRepository, showsRepository, cinemaSeatingRepository, ticketsRepository, reservationsRepository, mapper));
        }
Example #8
0
        public async Task NewShowInListWhenAdded()
        {
            //Arrange
            var context         = TheatreContextInit.InitializeContextInMemoryDb();
            var showsRepository = new ShowsRepository(context);
            var shows           = new Controllers.OnStageController(showsRepository);
            //Act
            var id = await shows.PostAsync(new Show()
            {
                Name      = "De Woof-side story",
                TimeSlots = new List <TimeSlot>()
                {
                    new TimeSlot()
                    {
                        Start = Convert.ToDateTime("01-06-2018 14:00", CultureInfo.CurrentCulture),
                        End   = Convert.ToDateTime("01-06-2018 15:00", CultureInfo.CurrentCulture)
                    }
                }
            });

            //Assert
            Assert.True(context.Shows.Any());
            Assert.Equal("De Woof-side story", context.Shows.Find(id).Name);
        }
        // ReSharper disable once InconsistentNaming
        public async Task GetFullShowsByTheTvDbIdsAsync_should_return_null_if_ids_array_is_empty()
        {
            using (var context = CreateContext())
            {
                await SeedGenresAsync(context);

                var repo = new ShowsRepository(context);

                var shows = await repo.GetFullShowsByTheTvDbIdsAsync(Array.Empty<int>());

                Assert.Equal(0, shows.Length);
            }
        }
Example #10
0
 public static bool DeleteShow(int id)
 {
     return(ShowsRepository.DeleteShow(id));
 }
Example #11
0
 public static Show GetShowByToken(string token)
 {
     return(ShowsRepository.GetShowByToken(token));
 }
Example #12
0
 public static bool CheckShowWithSeller(int showId, int UserId)
 {
     return(ShowsRepository.CheckShowWithSeller(showId, UserId));
 }
Example #13
0
 public static Show GetShowById(int id)
 {
     return(ShowsRepository.GetShowById(id));
 }
Example #14
0
 public static ShowDetail GetShowDetailById(int showId)
 {
     return(ShowsRepository.GetShowDetailById(showId));
 }
Example #15
0
 public static List <Show> GetShowBySellerId(int sellerId)
 {
     return(ShowsRepository.GetShowBySellerId(sellerId));
 }
Example #16
0
 public static List <Show> GetAllShow()
 {
     return(ShowsRepository.GetShow());
 }
Example #17
0
        public static bool InsertNewShow(int sellerid, string name, int price, string description)
        {
            Show newShow = ShowFactory.Create(sellerid, name, price, description);

            return(ShowsRepository.InsertShow(newShow));
        }
Example #18
0
 public ShowsController(MovieContext movieContext)
 {
     showsRepository       = new ShowsRepository(movieContext);
     resevationsRepository = new ResevationsRepository(movieContext);
 }
 public AndroidProjectController()
 {
     this.showsRepository = new ShowsRepository(new DbFactory());
     this.usersRepository = new UsersRepository(new DbFactory());
 }
Example #20
0
 public ActionResult <IEnumerable <string> > Get()
 {
     return(new string[] { "pageCount",
                           ShowsRepository.getTotalpageCount(showContext).ToString() });
 }
Example #21
0
 public ActionResult <IEnumerable <ShowDto> > Get(int page)
 {
     return(ShowsRepository.getPagedShows(showContext, page));
 }
Example #22
0
 public OnStageController(ShowsRepository repository)
 {
     _repository = repository;
 }
        // ReSharper disable once InconsistentNaming
        public async Task GetFullShowsByTheTvDbIdsAsync_should_return_null_if_no_id_matches()
        {
            using (var context = CreateContext())
            {
                await SeedGenresAsync(context);

                var repo = new ShowsRepository(context);

                int[] ids = {
                    999999999
                };

                var shows = await repo.GetFullShowsByTheTvDbIdsAsync(ids);

                Assert.Equal(0, shows.Length);
            }
        }