public async Task should_increment_the_visit_counter_when_slot_is_booked() { 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"); await Given(slotSchedule1, slotSchedule2, slotBooked1, slotBooked2); Then(2, await _repository.CountByPatientAndMonth("patient 1", _now.Month)); }
public async Task should_allow_to_book_slot() { var slotId = new SlotId(Guid.NewGuid()); var expected = new SlotBooked(_dayId.Value, slotId.Value, "John Doe"); Given( new DayScheduled(_dayId.Value, _doctorId.Value, _date), new SlotScheduled(slotId.Value, _dayId.Value, _date, TimeSpan.FromMinutes(10))); await When(new BookSlot(_dayId.Value, slotId.Value, "John Doe")); Then(e => { Assert.IsType <SlotBooked>(e.First()); Assert.Equal(expected, e.First()); }); }
public async Task should_issue_command_to_cancel_slot_if_booking_limit_was_reached() { 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 slotSchedule3 = new SlotScheduled(Guid.NewGuid(), dayId, _now.AddMinutes(20), _tenMinutes); var slotSchedule4 = new SlotScheduled(Guid.NewGuid(), dayId, _now.AddMinutes(30), _tenMinutes); var slotBooked1 = new SlotBooked(dayId, slotSchedule1.SlotId, "patient 1"); var slotBooked2 = new SlotBooked(dayId, slotSchedule2.SlotId, "patient 1"); var slotBooked3 = new SlotBooked(dayId, slotSchedule3.SlotId, "patient 1"); var slotBooked4 = new SlotBooked(dayId, slotSchedule4.SlotId, "patient 1"); await Given(slotSchedule1, slotSchedule2, slotSchedule3, slotSchedule4, slotBooked1, slotBooked2, slotBooked3, slotBooked4); Then( new CancelSlotBooking(dayId, slotBooked4.SlotId, "overbooked"), (await _esStore.LoadCommands("async_command_handler-day")).Last().Command); }
public async Task should_archive_all_events_and_truncate_all_except_last_one() { var dayId = Guid.NewGuid().ToString(); var scheduled = new SlotScheduled(Guid.NewGuid(), dayId, _now, _tenMinutes); var slotBooked = new SlotBooked(dayId, scheduled.SlotId, "PatientId"); var dayArchived = new DayScheduleArchived(dayId); var metadata = new CommandMetadata(new CorrelationId(Guid.NewGuid()), new CausationId(Guid.NewGuid())); var events = new List <object> { scheduled, slotBooked, dayArchived }; await _esStore.AppendEvents("Day-" + dayId, metadata, events.ToArray()); await Given(dayArchived); Then(events, _inMemoryColdStorage.Events); Then(new List <object> { dayArchived }, await _esStore.LoadEvents("Day-" + dayId)); }
private void When(SlotBooked @event) => _slots.MarkAsBooked(@event.SlotId);