public async void WithValidValues_ReturnsTrue() { var tablesGetAll = FakeTables.GetAll4x2Tables(); var bookingsGetByDate = FakeBookings.Get3Bookings(); _bookingRepository.GetByDate(Arg.Any <DateTime>()).Returns(bookingsGetByDate); _tableRepository.GetAll().Returns(tablesGetAll); var bookingService = new BookingService(_bookingRepository, _tableRepository); var bookingRequest = ValidBooking(0); var actual = await bookingService.ClientBookTable(bookingRequest); actual.Success.Should().BeTrue(); }
public async void BookTable_WithValidValues_CallsRepositoryAddAsync() { var tablesGetAll = FakeTables.GetAll4x2Tables(); var bookingsGetByDate = FakeBookings.Get3Bookings(); _bookingRepository.GetByDate(Arg.Any <DateTime>()).Returns(bookingsGetByDate); _tableRepository.GetAll().Returns(tablesGetAll); var bookingService = new BookingService(_bookingRepository, _tableRepository); var bookingRequest = ValidBooking(0); var actual = await bookingService.ClientBookTable(bookingRequest); await _bookingRepository.Received(1).AddAsync(Arg.Any <Booking>()); }
public async void Booking_AvailableTableTooSmall_ReturnsFalse() { var tablesGetAll = FakeTables.GetAll4x2Tables(); var bookingsGetByDate = FakeBookings.Get3Bookings(); _bookingRepository.GetByDate(Arg.Any <DateTime>()).Returns(bookingsGetByDate); _tableRepository.GetAll().Returns(tablesGetAll); var bookingService = new BookingService(_bookingRepository, _tableRepository); var bookingRequest = new BookingRequestModel() { Seats = 4, Email = "*****@*****.**", CustomerName = "notCoolguy", Time = DateTime.Now, PhoneNumber = "3758374" }; var actual = await bookingService.ClientBookTable(bookingRequest); actual.Success.Should().BeFalse(); }