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)); }
private void MockDB(BookMyTicketDBContext bookMyTicketDB) { bookMyTicketDB.Cities.Add(new Entities.City { ID = 1, Name = "City" }); bookMyTicketDB.Movies.Add(new Entities.Movie { ID = 1, Name = "Movie", Description = "Movie1", Duration = 120, Poster = "Poster", ReleaseDate = DateTime.Now }); bookMyTicketDB.CinemaSeating.Add(new Entities.CinemaSeating { ID = 1, SeatNumber = "A1", ColumnNumber = 0, RowNumber = 0, LayoutID = 1 }); bookMyTicketDB.CinemaSeating.Add(new Entities.CinemaSeating { ID = 2, SeatNumber = "A2", ColumnNumber = 0, RowNumber = 1, LayoutID = 1 }); bookMyTicketDB.Cinema.Add(new Entities.Cinema { ID = 1, Name = "Cinema", CityID = 1, LayoutID = 1 }); bookMyTicketDB.Shows.Add(new Entities.Show { ID = 1, CinemaID = 1, MovieID = 1, ShowTime = DateTime.Now, PricePerUnit = 123 }); bookMyTicketDB.Shows.Add(new Entities.Show { ID = 2, CinemaID = 1, MovieID = 1, ShowTime = DateTime.Now.AddDays(1), PricePerUnit = 13 }); bookMyTicketDB.SaveChanges(); }
public TicketService(IShowsRepository showsRepository, ITicketsRepository ticketsRepository, IReservationsRepository reservationsRepository, IClientContext clientContext, ISearchService searchService, IMapper mapper, BookMyTicketDBContext bookMyTicketDBContext) { _showsRepository = showsRepository; _ticketsRepository = ticketsRepository; _reservationsRepository = reservationsRepository; _clientContext = clientContext; _mapper = mapper; _searchService = searchService; _bookMyTicketDBContext = bookMyTicketDBContext; }
private UserService CreateSearchService() { var options = new DbContextOptionsBuilder <BookMyTicketDBContext>() .UseInMemoryDatabase(nameof(SearchServiceTest), new InMemoryDatabaseRoot()) .Options; var dbContext = new BookMyTicketDBContext(options); var userRepository = new UsersRepository(dbContext); var configuration = new MapperConfiguration(cfg => cfg.AddProfile(new MappingProfile())); var jwtIssuerOptions = new JwtIssuerOptions() { Audience = "https://localhost:44367/", Issuer = "BookMyTicketsWebApi" }; var mapper = new Mapper(configuration); return(new UserService(userRepository, jwtIssuerOptions, mapper)); }
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)); }
public MoviesRepository(BookMyTicketDBContext dbContext) : base(dbContext) { }
public UsersRepository(BookMyTicketDBContext dbContext) : base(dbContext) { }
public BaseRepository(BookMyTicketDBContext context) { _context = context; table = _context.Set <T>(); }
public CinemasRepository(BookMyTicketDBContext dbContext) : base(dbContext) { }
public ReservationsRepository(BookMyTicketDBContext dbContext) : base(dbContext) { }