public void TestImpossibleReservationsDueToLackOfTimeSlots() { for (int i = 0; i < this.lanes.Count; i++) { var reservation = new Reservation() { CreatedAt = DateTime.Now, Name = "Gert", NumberOfPlayers = 4, PhoneNumber = 1234, PlayAt = DateTime.Now }; reservation.AddLane(this.lanes[i]); reservation.AddTimeSlot((from y in this.timeSlots select y).First<TimeSlot>()); this._session.Save(reservation); } // since we filled out all lanes at that timeslot, the next booking for that timeslot should not be possible var service = new ReservationPossibleService(); var request = new ReservationPossible() { Reservation = new ReservationType() { HowManyHours = 2, NumberOfPlayers = 8, PlayAt = DateTime.Now, TimeOfDay = (from y in this.timeSlots select y).First<TimeSlot>().Start } }; ReservationPossibleResponse response = service.OnPost(request) as ReservationPossibleResponse; Assert.That(response.IsPossible, Is.False); Assert.That(response.Suggestions.Count, Is.EqualTo(2)); }
public void TestReservationPossibleInvalidPlayAt() { ReservationType resv = new ReservationType() { HowManyHours = 3, NumberOfPlayers = 20, PlayAt = DateTime.Now.AddDays(-1), TimeOfDay = TimeSpan.FromHours(13) }; ReservationPossible request = new ReservationPossible() { Reservation = resv }; ReservationPossibleValidator validator = new ReservationPossibleValidator(); var response = validator.Validate(request); Assert.That(response.IsValid, Is.False); Assert.That(response.Errors[0].PropertyName, Is.EqualTo("Reservation.PlayAt")); }
public void TestValidReservationWithNoOtherReservations() { var service = new ReservationPossibleService(); var request = new ReservationPossible() { Reservation = new ReservationType() { HowManyHours = 2, NumberOfPlayers = 4, PlayAt = DateTime.Now, TimeOfDay = TimeSpan.FromHours(10) } }; ReservationPossibleResponse response = service.OnPost(request) as ReservationPossibleResponse; Assert.That(response.IsPossible, Is.True); }
public ActionResult Index(ReservationInputModel model) { if (ModelState.IsValid) { try { var request = new ReservationPossible(); request.Reservation = Mapper.Map<ReservationType>(model); var response = this.CurrentAPIClient.Post<ReservationPossibleResponse>( "/reservation/possible", request); if (response.IsPossible) { this.CurrentReservation = Mapper.Map<ReservationType>(model); return RedirectToAction("ContactInfo"); } Information("Unfortunately this particular reservation is not possible, but please look at the page for suggestions."); model.Suggestions = response.Suggestions; return View(model); } catch (WebServiceException ex) { Error("Awww, something terrible happened. The Leprechauns are working on the problem se please try again later. Techical details: " + ex.Message); return View(model); } } Error("Darn, Something in your input was not correct. Please check it."); return View(model); }
public void TestReservationPossibleValidRequest1() { ReservationType resv = new ReservationType() { HowManyHours = 2, NumberOfPlayers = 20, PlayAt = DateTime.Now.AddDays(1), TimeOfDay = TimeSpan.FromHours(13) }; ReservationPossible request = new ReservationPossible() { Reservation = resv }; ReservationPossibleValidator validator = new ReservationPossibleValidator(); Assert.That(validator.Validate(request).IsValid, Is.True); }
public void TestValidResrvationWithSomeOtherReservations() { var reservation = new Reservation() { CreatedAt = DateTime.Now, Name = "Gert", NumberOfPlayers = 4, PhoneNumber = 1234, PlayAt =DateTime.Now }; reservation.AddLane((from y in this.lanes select y).First<Lane>()); reservation.AddTimeSlot((from y in this.timeSlots select y).First<TimeSlot>()); this._session.Save(reservation); var service = new ReservationPossibleService(); var request = new ReservationPossible() { Reservation = new ReservationType() { HowManyHours = 2, NumberOfPlayers = 8, PlayAt = DateTime.Now, TimeOfDay = (from y in this.timeSlots select y).First<TimeSlot>().Start } }; ReservationPossibleResponse response = service.OnPost(request) as ReservationPossibleResponse; Assert.That(response.IsPossible, Is.True); }