public async Task AddReservation_ShouldNotAddReservationWithInvalidDate() { // Arange ApplicationDbContext context = InMemoryFactory.InitializeContext(); SettingService settingService = new(context); var service = new ReservationsService(context, settingService); // Act var reservation1 = await service.AddReservation(Reservations.Reservation5User3Room1NoClient.Room.Id, Reservations.Reservation5User3Room1NoClient.AccommodationDate, Reservations.Reservation5User3Room1NoClient.ReleaseDate, Reservations.AllInClusive1, Reservations.Breakfast1, Reservations.Reservation5User3Room1NoClient.Clients, Reservations.Reservation5User3Room1NoClient.User); var reservation2 = await service.AddReservation(Reservations.Reservation6User3Room1NoClient.Room.Id, Reservations.Reservation6User3Room1NoClient.AccommodationDate, Reservations.Reservation6User3Room1NoClient.ReleaseDate, Reservations.AllInClusive1, Reservations.Breakfast1, Reservations.Reservation6User3Room1NoClient.Clients, Reservations.Reservation6User3Room1NoClient.User); // Assert Assert.Null(reservation1); Assert.Null(reservation2); }
public async Task AddReservation_ShouldNotAddReservation() { // Arange List <Reservation> reservationsData = new() { Reservations.Reservation3User4Room2NoClient }; List <Room> rooms = new() { Rooms.Room2 }; ApplicationDbContext context = await InMemoryFactory.InitializeContext() .SeedAsync(rooms) .SeedAsync(reservationsData); SettingService settingService = new(context); var service = new ReservationsService(context, settingService); // Act var reservation = await service.AddReservation(Reservations.Reservation4User4Room2NoClient.Room.Id, Reservations.Reservation4User4Room2NoClient.AccommodationDate, Reservations.Reservation4User4Room2NoClient.ReleaseDate, Reservations.AllInClusive1, Reservations.Breakfast1, Reservations.Reservation4User4Room2NoClient.Clients, Reservations.Reservation4User4Room2NoClient.User); // Assert Assert.Null(reservation); }
public async Task AddReservation_ShouldAddReservation() { // Arange List <Setting> settings = new() { Settings.AllInclusive, Settings.Breakfast }; List <Room> rooms = new() { Rooms.Room1 }; List <ApplicationUser> users = new() { Users.User3NotEmployee }; ApplicationDbContext context = await InMemoryFactory.InitializeContext() .SeedAsync(settings) .SeedAsync(users) .SeedAsync(rooms); SettingService settingService = new(context); var service = new ReservationsService(context, settingService); // Act var reservation = await service.AddReservation(Reservations.Reservation1User3Room1NoClient.Room.Id, Reservations.Reservation1User3Room1NoClient.AccommodationDate, Reservations.Reservation1User3Room1NoClient.ReleaseDate, Reservations.AllInClusive1, Reservations.Breakfast1, Reservations.Reservation1User3Room1NoClient.Clients, Reservations.Reservation1User3Room1NoClient.User ); // Assert Assert.NotNull(reservation); Assert.AreEqual(1, context.Reservations.Count()); }
public IActionResult Create(ReservationsCreateVM reservation) { service.AddReservation(reservation); return(RedirectToAction(nameof(Index))); }