Exemplo n.º 1
0
    public async Task should_hide_the_slot_from_list_if_booked()
    {
        var scheduled = new SlotScheduled(Guid.NewGuid(), "dayId", _now, _tenMinutes);

        await Given(
            scheduled,
            new SlotBooked("dayId", scheduled.SlotId, "PatientId"));

        Then(new List <AvailableSlot>(), await _repository.GetAvailableSlotsOn(_now));
    }
Exemplo n.º 2
0
    public async Task should_delete_slot_if_slot_was_cancelled()
    {
        var scheduled = new SlotScheduled(Guid.NewGuid(), "dayId", _now, _tenMinutes);

        await Given(
            scheduled,
            new SlotScheduleCancelled("dayId", scheduled.SlotId));

        Then(new List <AvailableSlot>(), await _repository.GetAvailableSlotsOn(_now));
    }
Exemplo n.º 3
0
    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));
    }
Exemplo n.º 4
0
    public async Task should_add_slot_to_the_list()
    {
        var scheduled = new SlotScheduled(Guid.NewGuid(), "dayId", _now, _tenMinutes);

        await Given(scheduled);

        Then(
            new AvailableSlot(
                scheduled.SlotId.ToString(),
                scheduled.DayId,
                scheduled.SlotStartTime.Date.ToString("dd-MM-yyyy"),
                scheduled.SlotStartTime.ToString("h:mm tt"),
                scheduled.SlotDuration
                ), (await _repository.GetAvailableSlotsOn(_now)).First());
    }
Exemplo n.º 5
0
    public async Task allow_to_schedule_an_extra_slot()
    {
        var slotId   = new SlotId(Guid.NewGuid());
        var duration = TimeSpan.FromMinutes(10);
        var expected = new SlotScheduled(slotId.Value, _dayId.Value, _date, duration);

        Given(new DayScheduled(_dayId.Value, _doctorId.Value, _date));

        await When(new ScheduleSlot(slotId.Value, _doctorId.Value, _date, duration, _date));

        Then(e =>
        {
            Assert.IsType <SlotScheduled>(e.First());
            Assert.Equal(expected, e.First());
        });
    }
Exemplo n.º 6
0
    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);
    }
Exemplo n.º 7
0
    public async Task should_show_slot_if_booking_was_cancelled()
    {
        var scheduled = new SlotScheduled(Guid.NewGuid(), "dayId", _now, _tenMinutes);

        await Given(
            scheduled,
            new SlotBooked("dayId", scheduled.SlotId, "PatientId"),
            new SlotBookingCancelled("dayId", scheduled.SlotId, "Reason"));

        Then(new List <AvailableSlot>
        {
            new AvailableSlot(
                scheduled.SlotId.ToString(),
                scheduled.DayId,
                scheduled.SlotStartTime.Date.ToString("dd-MM-yyyy"),
                scheduled.SlotStartTime.ToString("h:mm tt"),
                scheduled.SlotDuration
                )
        }, await _repository.GetAvailableSlotsOn(_now));
    }
    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));
    }
Exemplo n.º 9
0
 private void When(SlotScheduled @event) =>
 _slots.Add(@event.SlotId, @event.SlotStartTime, @event.SlotDuration, false);