public void Not_Book_Hotel_When_There_Is_Another_Book_In_The_Same_Period_For_The_Same_Costumer() { IEnumerable <DateTime> dates = new DateTime[] { new DateTime(2019, 09, 22) }; BookingSpecification bookingSpecification = new BookingSpecification(Guid.NewGuid(), Guid.NewGuid(), dates); Customer costumer = new Customer { Id = bookingSpecification.CostumerId }; Hotel hotel = CreateHotel(bookingSpecification.HotelId); Booking booking = new Booking(hotel, costumer, dates, 50); hotel.Bookings = new List <Booking> { booking }; costumer.Bookings = new List <Booking> { booking }; hotelRepository.Setup(h => h.GetById(bookingSpecification.HotelId)).Returns(hotel); costumerRepository.Setup(h => h.GetById(bookingSpecification.CostumerId)).Returns(costumer); bookHotel.Do(bookingSpecification); Assert.AreEqual(1, hotel.Bookings.Count); }
public void BookHotel(BookingSpecification bookingSpecification) { Hotel hotel = HotelRepository.GetById(bookingSpecification.HotelId); Customer costumer = CostumerRepository.GetById(bookingSpecification.CostumerId); hotel.Book(costumer, bookingSpecification.Dates); }
public void Calculate_Total_Price_For_The_Booking() { IEnumerable <DateTime> dates = new DateTime[] { new DateTime(2019, 09, 21), new DateTime(2019, 09, 22), new DateTime(2019, 09, 23) }; BookingSpecification bookingSpecification = new BookingSpecification(Guid.NewGuid(), Guid.NewGuid(), dates); Hotel hotel = CreateHotel(bookingSpecification.HotelId); Customer costumer = new Customer { Id = bookingSpecification.CostumerId }; hotelRepository.Setup(h => h.GetById(bookingSpecification.HotelId)).Returns(hotel); costumerRepository.Setup(h => h.GetById(bookingSpecification.CostumerId)).Returns(costumer); bookHotel.Do(bookingSpecification); Assert.AreEqual(200, hotel.Bookings.Single().TotalPrice); }
public void Add_Booking_To_Costumer() { BookingSpecification bookingSpecification = new BookingSpecification(Guid.NewGuid(), Guid.NewGuid(), new DateTime[] { new DateTime(2019, 09, 22) }); Hotel hotel = CreateHotel(bookingSpecification.HotelId); Customer costumer = new Customer { Id = bookingSpecification.CostumerId }; hotelRepository.Setup(h => h.GetById(bookingSpecification.HotelId)).Returns(hotel); costumerRepository.Setup(h => h.GetById(bookingSpecification.CostumerId)).Returns(costumer); bookHotel.Do(bookingSpecification); Assert.AreEqual(1, costumer.Bookings.Count); Assert.AreEqual(hotel, costumer.Bookings.Single().Hotel); Assert.AreEqual(costumer, costumer.Bookings.Single().Customer); Assert.AreEqual(bookingSpecification.Dates, costumer.Bookings.Single().Dates); }