예제 #1
0
        public async Task Test_AddCustomRule_ShouldThrowException()
        {
            const int maxSeats     = 5;
            var       desiredSeats = CreateSeats().Where(s => s.Id <= (long)maxSeats).Select(Map).ToList();

            PrepareReservationMocks(maxSeats, ScheduleA, ScheduleB, desiredSeats);

            _reservationService.ClearRules();                           // no rules active -> normally it would throw
            _reservationService.AddRule(new SeatAvailableValidation()); // add seat available rule -> should throw now
            Func <Task <ReservationDto> > addReservationAsync = async() => await _reservationService.AddReservationAsync(desiredSeats, ScheduleB.Id, 2L);

            await addReservationAsync.Should().ThrowExactlyAsync <SeatValidationException>();
        }