public async Task Check_ConferenceHall_Seeder() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; this.dbContext = new ApplicationDbContext(options); var conferenceHallRepository = new EfDeletableEntityRepository <ConferenceHall>(this.dbContext); var conferenceHallReservationRepository = new EfDeletableEntityRepository <ConferenceHallReservation>(this.dbContext); await conferenceHallRepository.AddAsync(new ConferenceHall { Id = "conferenceid", CreatedOn = DateTime.UtcNow, IsDeleted = false, EventType = (ConfHallEventType)Enum.Parse(typeof(ConfHallEventType), "Conference"), Description = "Conference", CurrentCapacity = 100, MaxCapacity = 100, Price = 50, }); await conferenceHallRepository.SaveChangesAsync(); this.conferenceHallService = new ConferenceHallService(conferenceHallReservationRepository, conferenceHallRepository); var actualResult = conferenceHallRepository.All().ToList(); int expectedResult = 1; Assert.Equal(actualResult.Count(), expectedResult); }
public async Task Reserve_ConferenceHall_Should_Decrease_Halls_Capacity() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; this.dbContext = new ApplicationDbContext(options); var conferenceHallRepository = new EfDeletableEntityRepository <ConferenceHall>(this.dbContext); var conferenceHallReservationRepository = new EfDeletableEntityRepository <ConferenceHallReservation>(this.dbContext); await conferenceHallRepository.AddAsync(new ConferenceHall { Id = "conferenceid", CreatedOn = DateTime.UtcNow, IsDeleted = false, EventType = (ConfHallEventType)Enum.Parse(typeof(ConfHallEventType), "Conference"), Description = "Conference", CurrentCapacity = 100, MaxCapacity = 100, Price = 50, }); await conferenceHallRepository.SaveChangesAsync(); this.conferenceHallService = new ConferenceHallService(conferenceHallReservationRepository, conferenceHallRepository); var reservation = new ConferenceHallInputModel { EventDate = DateTime.Now.AddDays(1), CheckIn = DateTime.Now.AddDays(1).AddHours(10), CheckOut = DateTime.Now.AddDays(1).AddHours(11), NumberOfGuests = 50, EmailAddress = "*****@*****.**", FirstName = "Marian", LastName = "Kyuchukov", PhoneNumber = "0888186978", EventType = (ConfHallEventType)Enum.Parse(typeof(ConfHallEventType), "Conference"), }; var result = await this.conferenceHallService.ReserveConferenceHall(reservation); var parsedEventType = (ConfHallEventType)Enum.Parse(typeof(ConfHallEventType), "Conference"); var actualResult = conferenceHallRepository.All().FirstOrDefault(x => x.EventType == parsedEventType).CurrentCapacity; var expected = 50; Assert.Equal(expected, actualResult); }
public async Task Get_All_Reservations_Should_Return_All_Reservations() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; this.dbContext = new ApplicationDbContext(options); var conferenceHallRepository = new EfDeletableEntityRepository <ConferenceHall>(this.dbContext); var conferenceHallReservationRepository = new EfDeletableEntityRepository <ConferenceHallReservation>(this.dbContext); await conferenceHallRepository.AddAsync(new ConferenceHall { Id = "conferenceid", CreatedOn = DateTime.UtcNow, IsDeleted = false, EventType = (ConfHallEventType)Enum.Parse(typeof(ConfHallEventType), "TeamBuilding"), Description = "TeamBuilding", CurrentCapacity = 100, MaxCapacity = 100, Price = 50, }); await conferenceHallRepository.SaveChangesAsync(); conferenceHallReservationRepository.AddAsync(new ConferenceHallReservation { EventDate = DateTime.Now, CheckIn = DateTime.Now.AddHours(2), CheckOut = DateTime.Now.AddHours(3), NumberOfGuests = 50, PhoneNumber = "0888186978", EventType = (ConfHallEventType)Enum.Parse(typeof(ConfHallEventType), "TeamBuilding"), ConferenceHallId = "conferenceid", UserId = "1", }).GetAwaiter().GetResult(); await conferenceHallReservationRepository.SaveChangesAsync(); this.conferenceHallService = new ConferenceHallService(conferenceHallReservationRepository, conferenceHallRepository); int expectedResult = 1; var actualResult = await this.conferenceHallService.GetAllReservationsAsyncForAdmin <ConfHallAllViewModel>(); Assert.Equal(actualResult.Count(), expectedResult); }
public async Task Reserve_ConferenceHall_Should_Reserve_Correctly_EventType() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; this.dbContext = new ApplicationDbContext(options); var conferenceHallRepository = new EfDeletableEntityRepository <ConferenceHall>(this.dbContext); var conferenceHallReservationRepository = new EfDeletableEntityRepository <ConferenceHallReservation>(this.dbContext); await conferenceHallRepository.AddAsync(new ConferenceHall { Id = "conferenceid", CreatedOn = DateTime.UtcNow, IsDeleted = false, EventType = (ConfHallEventType)Enum.Parse(typeof(ConfHallEventType), "TeamBuilding"), Description = "TeamBuilding", CurrentCapacity = 100, MaxCapacity = 100, Price = 50, }); await conferenceHallRepository.SaveChangesAsync(); this.conferenceHallService = new ConferenceHallService(conferenceHallReservationRepository, conferenceHallRepository); conferenceHallReservationRepository.AddAsync(new ConferenceHallReservation { EventDate = DateTime.Now, CheckIn = DateTime.Now.AddHours(2), CheckOut = DateTime.Now.AddHours(3), NumberOfGuests = 50, PhoneNumber = "0888186978", EventType = (ConfHallEventType)Enum.Parse(typeof(ConfHallEventType), "TeamBuilding"), ConferenceHallId = "conferenceid", }).GetAwaiter().GetResult(); await conferenceHallReservationRepository.SaveChangesAsync(); var actualResult = conferenceHallReservationRepository.All().FirstOrDefault(x => x.ConferenceHallId == "conferenceid").EventType.ToString(); var expected = "TeamBuilding"; Assert.Equal(expected, actualResult); }