public void CreateBooking_WhileFullyBooked_Fails() { var bookingCreated = bookingManager.CreateBooking( new Booking { StartDate = DateTime.Today.AddDays(15), EndDate = DateTime.Today.AddDays(16) }); bookingCreated.Should().BeFalse(); }
public void CreateBooking_RoomAvailable_ReturnsTrue() { BookingManager manager = CreateBookingManager(); DateTime date = DateTime.Today.AddDays(21); Booking b = new Booking { StartDate = date, EndDate = date, }; bool result = manager.CreateBooking(b); Assert.IsTrue(result); }
public IHttpActionResult PostBooking([FromBody] BookingDto rc) { BookingManager rm = new BookingManager(); IMapper iMapper = AutomapperInitialize(); var source = rc; var destination = iMapper.Map <BookingDto, Booking>(source); rm.CreateBooking(destination); return(Ok()); }
public void TestCreateBooking_ReturnTrueCreated() { // Create a Booking Object & Assign the Start and End date Booking book = new Booking(); book.StartDate = time.DtS; book.EndDate = time.DtE; // Test Assert.True(bm.CreateBooking(book)); }
private void RegisterBookingBtn_Click(object sender, EventArgs e) { var clientId = ClientIdTxtField.Text; var droneId = DroneIdTxtField.Text; var dateTaken = DateTakenPicker.Checked ? DateTakenPicker.Value.ToString("yyyy-MM-dd hh:mm:ss") : null; var dateDue = DateDuePicker.Checked ? DateDuePicker.Value.ToString("yyyy-MM-dd hh:mm:ss") : null; var results = _bookingManager.CreateBooking(droneId, clientId, dateTaken, dateDue); ResultBookingTxtArea.Text += results; }
public void WhenIBookARoom() { _booking = new Booking { Id = 1, StartDate = DateTime.Today.AddDays(_startDate), EndDate = DateTime.Today.AddDays(_endDate), CustomerId = 1, IsActive = false }; _isCreated = bm.CreateBooking(_booking); }
public IActionResult Create([Bind("StartDate,EndDate,CustomerId")] Booking booking) { if (ModelState.IsValid) { bool created = bookingManager.CreateBooking(booking); if (created) { return(RedirectToAction(nameof(Index))); } } ViewData["CustomerId"] = new SelectList(customerRepository.GetAll(), "Id", "Name", booking.CustomerId); ViewBag.Status = "The booking could not be created. There were no available room."; return(View(booking)); }
public IActionResult Create(BookingModel model) { if (ModelState.IsValid) { var result = booking.CreateBooking(model.Name); if (String.IsNullOrEmpty(result)) { return(RedirectToAction("Category", "Movies")); } else { ModelState.AddModelError("validation", result); } } return(View(model)); }
public void CreateBooking_InvalidInput_ThrowsArgumentException(int stNo, int edNo) { Booking newBooking = new Booking { Id = 4, StartDate = DateTime.Today.AddDays(stNo), EndDate = DateTime.Today.AddDays(edNo), CustomerId = 1, RoomId = 1, IsActive = true }; BookingManager manager = CreateBookingManager(newBooking); var createdBooking = Assert.Throws <ArgumentException>(() => manager.CreateBooking(newBooking)); StringAssert.Contains("Start and end date cannot be set to before current date, and the start date later than the end date", createdBooking.Message); }
// [Test] public void CreateBooking_StartDateMinusOne_EndDatePlusOne() { DateTime startDate = DateTime.Today.AddDays(-1); DateTime endDate = DateTime.Today.AddDays(1); Booking newBooking = new Booking { Id = 4, StartDate = startDate, EndDate = endDate, CustomerId = 1, RoomId = 1, IsActive = true }; BookingManager bookingManager = CreateBookingManager(newBooking); var createdBooking = Assert.Throws <ArgumentException>(() => bookingManager.CreateBooking(newBooking)); StringAssert.Contains("Start and end date cannot be set to before current date, and end date should not be later than start date", createdBooking.Message); }
public void CreateBooking_InValidInputInOccupied_NotCreated(int stNo, int edNo) { DateTime startdate = DateTime.Today.AddDays(stNo); DateTime enddate = DateTime.Today.AddDays(edNo); Booking newBooking = new Booking { Id = 4, StartDate = startdate, EndDate = enddate, CustomerId = 1, RoomId = 1, IsActive = true }; BookingManager manager = CreateBookingManager(newBooking); var createdBooking = manager.CreateBooking(newBooking); Assert.AreEqual(null, createdBooking); }
// [Test] public void CreateBooking_StartDatePlusTwentyOne_EndDatePlusTwentyTwo() { DateTime startDate = DateTime.Today.AddDays(21); DateTime endDate = DateTime.Today.AddDays(22); Booking newBooking = new Booking { Id = 4, StartDate = startDate, EndDate = endDate, CustomerId = 1, RoomId = 1, IsActive = true }; BookingManager bookingManager = CreateBookingManager(newBooking); var createdBooking = bookingManager.CreateBooking(newBooking); Assert.AreEqual(newBooking, createdBooking); }
//[Test] public void CreateBooking_StartEqualsEndDateMaxInOccupied_NotCreated() { DateTime date = DateTime.Today.AddDays(20); DateTime date2 = DateTime.Today.AddDays(20); Booking newBooking = new Booking { Id = 4, StartDate = date2, EndDate = date, CustomerId = 1, RoomId = 1, IsActive = true }; BookingManager manager = CreateBookingManager(newBooking); var createdBooking = manager.CreateBooking(newBooking); Assert.AreEqual(null, createdBooking); }
//[Test] public void CreateBooking_EndDateIsLargerThanStartDate_BookingIsCreated() { DateTime date = DateTime.Today.AddDays(1); DateTime date2 = DateTime.Today.AddDays(2); Booking newBooking = new Booking { Id = 4, StartDate = date, EndDate = date2, CustomerId = 1, RoomId = 1, IsActive = true }; BookingManager manager = CreateBookingManager(newBooking); var createdBooking = manager.CreateBooking(newBooking); Assert.AreEqual(newBooking, createdBooking); }
public void CreateBooking_ValidInput_BookingIsCreated(int stNo, int edNo) { DateTime date = DateTime.Today.AddDays(stNo); DateTime date2 = DateTime.Today.AddDays(edNo); Booking newBooking = new Booking { Id = 4, StartDate = date, EndDate = date2, CustomerId = 1, RoomId = 1, IsActive = true }; BookingManager manager = CreateBookingManager(newBooking); var createdBooking = manager.CreateBooking(newBooking); Assert.AreEqual(newBooking, createdBooking); }
// [Test] public void CreateBooking_StartDateIsLargerThanEndDate_NotCreated() { DateTime date = DateTime.Today.AddDays(1); DateTime date2 = DateTime.Today.AddDays(2); Booking newBooking = new Booking { Id = 4, StartDate = date2, EndDate = date, CustomerId = 1, RoomId = 1, IsActive = true }; BookingManager manager = CreateBookingManager(newBooking); var createdBooking = Assert.Throws <ArgumentException>(() => manager.CreateBooking(newBooking)); StringAssert.Contains("Start and end date cannot be set to before current date, and end date should not be later than start date", createdBooking.Message); }
public IActionResult Create([Bind("StartDate,EndDate,UserId,RoomId,OtelId")] Booking booking) { if (ModelState.IsValid) { ServiceCallResult created = bookingManager.CreateBooking(booking); if (created.Success) { TempData["SuccessNotification"] = created.SuccessMessages; //return RedirectToAction(nameof(Index)); return(View(booking)); } else { TempData["ErrorNotification"] = created.ErrorMessages; return(View(booking)); } } //ViewData["CustomerId"] = new SelectList(customerRepository.GetAll(),"Id", "Name", booking.UserId); ViewBag.Status = "Rezervasyon oluşturulamadı, mevcut oda bulunmamakta."; return(View(booking)); }
public void ThenTheResultShouldBeCreatedTheBookingTrue() { Assert.True(bookingManager.CreateBooking(booking)); }
public bool Post([FromBody] Booking value) { return(manager.CreateBooking(value)); }
public bool Post([FromBody] Bookings value) { //value.OrdNr = idCount++; return(manager.CreateBooking(value)); }