Exemple #1
0
        [TestCase(4, 11, false, "There is an existing booking")]  // Should fail - booking encompasses an existing booking
        public void DoctorCannotBeDoubleBooked(
            int requestStartOffset,
            int requestEndOffset,
            bool pass,
            string expectedError = default)
        {
            var requestStartTime = Now.AddTicks(requestStartOffset);
            var requestEndTime   = Now.AddTicks(requestEndOffset);

            var validator = new BookingRequestValidator(_context, _dateProvider);

            var bookingRequest = new BookingRequest
            {
                StartTime = requestStartTime,
                EndTime   = requestEndTime,
                DoctorId  = _doctorId
            };

            var result = validator.ValidateRequest(bookingRequest);

            Assert.That(result.PassedValidation, Is.EqualTo(pass));

            if (pass)
            {
                Assert.That(result.Errors, Is.Empty);
            }
            else
            {
                Assert.That(result.Errors.Single(), Is.EqualTo(expectedError));
            }
        }
Exemple #2
0
        public void BookingsCannotBeInThePast(int startOffset, int endOffset, bool pass, string expectedError = null)
        {
            var requestStartTime = Now.AddTicks(startOffset);
            var requestEndTime   = Now.AddTicks(endOffset);

            var validator = new BookingRequestValidator(_context, _dateProvider);

            var bookingRequest = new BookingRequest
            {
                StartTime = requestStartTime,
                EndTime   = requestEndTime
            };

            var result = validator.ValidateRequest(bookingRequest);

            Assert.That(result.PassedValidation, Is.EqualTo(pass));
            if (pass)
            {
                Assert.That(result.Errors, Is.Empty);
            }
            else
            {
                Assert.That(result.Errors.Single(), Is.EqualTo(expectedError));
            }
        }