public async Task cancel_booked_slots_when_the_day_is_cancelled() { var slotOneId = new SlotId(Guid.NewGuid()); var slotTwoId = new SlotId(Guid.NewGuid()); var slotCancelledExpected = new SlotBookingCancelled(_dayId.Value, slotOneId.Value, null); var slotOneScheduleCancelledExpected = new SlotScheduleCancelled(_dayId.Value, slotOneId.Value); var slotTwoScheduleCancelledExpected = new SlotScheduleCancelled(_dayId.Value, slotTwoId.Value); var dayCancelledExpected = new DayScheduleCancelled(_dayId.Value); Given( new DayScheduled(_dayId.Value, _doctorId.Value, _date), new SlotScheduled(slotOneId.Value, _dayId.Value, _date, TimeSpan.FromMinutes(10)), new SlotScheduled(slotTwoId.Value, _dayId.Value, _date, TimeSpan.FromMinutes(10)), new SlotBooked(_dayId.Value, slotOneId.Value, "John Doe")); await When(new CancelDaySchedule(_dayId.Value)); Then(e => { Assert.IsType <SlotBookingCancelled>(e[0]); Assert.Equal(slotCancelledExpected, e[0]); Assert.IsType <SlotScheduleCancelled>(e[1]); Assert.Equal(slotOneScheduleCancelledExpected, e[1]); Assert.IsType <SlotScheduleCancelled>(e[2]); Assert.Equal(slotTwoScheduleCancelledExpected, e[2]); Assert.IsType <DayScheduleCancelled>(e[3]); Assert.Equal(dayCancelledExpected, e[3]); }); }
public async Task should_decrement_the_visit_counter_when_slot_booking_is_cancelled() { var dayId = Guid.NewGuid().ToString(); var slotSchedule1 = new SlotScheduled(Guid.NewGuid(), dayId, _now, _tenMinutes); var slotSchedule2 = new SlotScheduled(Guid.NewGuid(), dayId, _now.AddMinutes(10), _tenMinutes); var slotBooked1 = new SlotBooked(dayId, slotSchedule1.SlotId, "patient 1"); var slotBooked2 = new SlotBooked(dayId, slotSchedule2.SlotId, "patient 1"); var slotBookingCancelled = new SlotBookingCancelled(dayId, slotSchedule2.SlotId, "no longer needed"); await Given(slotSchedule1, slotSchedule2, slotBooked1, slotBooked2, slotBookingCancelled); Then(1, await _repository.CountByPatientAndMonth("patient 1", _now.Month)); }
public async Task allow_to_cancel_booking() { var slotId = new SlotId(Guid.NewGuid()); var reason = "Cancel Reason"; var expected = new SlotBookingCancelled(_dayId.Value, slotId.Value, reason); Given( new DayScheduled(_dayId.Value, _doctorId.Value, _date), new SlotScheduled(slotId.Value, _dayId.Value, _date, TimeSpan.FromMinutes(10)), new SlotBooked(_dayId.Value, slotId.Value, "John Doe")); await When(new CancelSlotBooking(_dayId.Value, slotId.Value, reason)); Then(e => { Assert.IsType <SlotBookingCancelled>(e.First()); Assert.Equal(expected, e.First()); }); }
private void When(SlotBookingCancelled @event) => _slots.MarkAsAvailable(@event.SlotId);