public void OnCancelTableReservation_ReturnSuccess() { var bookingId = Guid.NewGuid(); var bookingDetail = new BookingDetail() { BookingId = bookingId, BookingDate = new DateTime(2015, 08, 29), CheckInTime = new TimeSpan(13, 30, 00), TableId = 1, CustomerDetail = new Person() { FirstName = "Balachandar", MobileNumber = "903-555-7303" } }; // Book the table reservation reservationBL.BookTableReservation(bookingDetail); // Cancel reservation reservationBL.CancelTableReservation(bookingDetail.BookingDate, bookingId); // Get the booking detail by passing booking id, it should return null value once cancelled var bookingDetailAfterCancellation = reservationBL.GetBookingDetail(bookingDetail.BookingDate, bookingId); Assert.IsNull(bookingDetailAfterCancellation.Result); }
/// <summary> /// Book the table reservation /// </summary> /// <param name="bookingDetail">Booking detais</param> /// <returns></returns> public ServiceResponse<bool> BookTableReservation(BookingDetail bookingDetail) { // Add business rules var serviceResponse = new ServiceResponse<bool>(); try { var result = reservationRepository.BookTableReservation(bookingDetail); serviceResponse.Result = result; if (result == true) { serviceResponse.OperationSuccess = true; serviceResponse.ServiceMessage = "Booking successful"; } else { serviceResponse.OperationSuccess = false; serviceResponse.ServiceMessage = "Unable to book the reservation"; } } catch (Exception ex) { serviceResponse.ErrorMessage = ex.Message; } return serviceResponse; }
public void OnBookingTableReservationWithValidValue_ReturnSuccess() { var bookingDetail = new BookingDetail() { BookingId = Guid.NewGuid(), BookingDate = new DateTime(2015, 08, 29), CheckInTime = new TimeSpan(13, 30, 00), TableId = 1, CustomerDetail = new Person() { FirstName = "Balachandar", MobileNumber = "903-555-7303" } }; var result = reservationBL.BookTableReservation(bookingDetail); Assert.IsTrue(result.OperationSuccess); }
/// <summary> /// Book table reservation /// </summary> /// <param name="bookingDetail"></param> /// <returns>true / false</returns> public bool BookTableReservation(BookingDetail bookingDetail) { var bookingDate = bookingDetail.BookingDate; // Check the data file is exist or not, if not exist creates the data file CreateDataFileIfNotExis(bookingDate); // Cancel if the booking is exist CancelTableReservation(bookingDate, bookingDetail.BookingId); // Get the booking details var bookingDetails = GetBookingDetails(bookingDate); //Add booking detail into list of booking details bookingDetails.Add(bookingDetail); // Serialize and save the Json text into a data file var dataFileName = GetDataFileName(bookingDate); return SerializerHelper.WriteIntoFile(bookingDetails, dataFileName); }
public void OnGetBookingDetails_ReturnSuccess() { var bookingDate = DateTime.Today; var bookingDetail1 = new BookingDetail() { BookingId = Guid.NewGuid(), BookingDate = bookingDate, CheckInTime = new TimeSpan(13, 30, 00), TableId = 1, CustomerDetail = new Person() { FirstName = "Balachandar", MobileNumber = "903-555-7303" } }; var bookingDetail2 = new BookingDetail() { BookingId = Guid.NewGuid(), BookingDate = bookingDate, CheckInTime = new TimeSpan(13, 30, 00), TableId = 1, CustomerDetail = new Person() { FirstName = "Ramesh", MobileNumber = "903-444-7303" } }; // Book the table reservation reservationBL.BookTableReservation(bookingDetail1); reservationBL.BookTableReservation(bookingDetail2); // Get the booking detail by passing booking date, it should return one ot more records var bookingDetailAfterAddingTwoRecords = reservationBL.GetBookingDetails(bookingDate); Assert.IsTrue(bookingDetailAfterAddingTwoRecords.Result.Count==2); }
public void OnUpdateTableReservationWithNewMobileNumber_ReturnSuccess() { var bookingId = Guid.NewGuid(); var bookingDetail = new BookingDetail() { BookingId = bookingId, BookingDate = new DateTime(2015, 08, 29), CheckInTime = new TimeSpan(13, 30, 00), TableId = 1, CustomerDetail = new Person() { FirstName = "Balachandar", MobileNumber = "903-555-7303" } }; // Book the table reservation reservationBL.BookTableReservation(bookingDetail); // Modify the Mobile number var mobileNumber = "111 222 3333"; bookingDetail.CustomerDetail.MobileNumber = mobileNumber; // Update the reservation reservationBL.UpdateTableReservation(bookingDetail); // Get the booking detail by passing booking id var bookingDetailAfterModification = reservationBL.GetBookingDetail(bookingDetail.BookingDate, bookingId); Assert.AreEqual(bookingDetailAfterModification.Result.CustomerDetail.MobileNumber, mobileNumber); }
public void OnGetTableAvailablity_WithValidLaterCheckinTime_ReturnSuccess() { // Table id :3 // Already Booked time : 10:30 // Maximum stay time : 60 Mins // Requested Checkin time : 11:30 // Expected value is True var bookingDate = DateTime.Today; var bookingId = Guid.NewGuid(); var bookingDetail = new BookingDetail() { BookingId = bookingId, BookingDate = bookingDate, CheckInTime = new TimeSpan(10, 30, 00), TableId = 3, CustomerDetail = new Person() { FirstName = "Balachandar", MobileNumber = "903-555-7303" } }; // Booking for 10:30 am and Table id : 3 reservationBL.BookTableReservation(bookingDetail); // Get availablity for 11:30 var availableTables=reservationBL.GetTableAvailablity(bookingDate, new TimeSpan(11, 30, 00)); // Check table id : 3 is available or not var table3Availablity = availableTables.Result.Where(tbl => tbl.TableId == 3).FirstOrDefault(); Assert.IsTrue(table3Availablity.IsAvailable); }
public void OnGetBookingDetail_ReturnSuccess() { var bookingDate = DateTime.Today; var bookingId = Guid.NewGuid(); var bookingDetail = new BookingDetail() { BookingId = bookingId, BookingDate = bookingDate, CheckInTime = new TimeSpan(13, 30, 00), TableId = 3, CustomerDetail = new Person() { FirstName = "Balachandar", MobileNumber = "903-555-7303" } }; // Book the table reservation reservationBL.BookTableReservation(bookingDetail); // Get the booking detail by passing booking date and booking id var bookingDetailAfterAddingOneRecord = reservationBL.GetBookingDetail(bookingDate, bookingId); // Check the table id value Assert.AreEqual(bookingDetailAfterAddingOneRecord.Result.TableId, 3); }
public bool UpdateTableReservation(BookingDetail bookingDetail) { // Cancel existing booking CancelTableReservation(bookingDetail.BookingDate, bookingDetail.BookingId); // Save the udated booking detail return BookTableReservation(bookingDetail); }