public async Task GivenValidCandidate_WhenCreatingBooking_ShouldGetDetailsFromCandidate()
        {
            var candidateRepository = BookingCandidateRepositoryTest.CreateBookingCandidateRepositoryForTest();
            var newCandidate        = BookingCandidateRepositoryTest.GetBookingCandidateForTest();

            const int placeInQueue = 1;
            var       candidateId  = await candidateRepository.CreateAsync(newCandidate);

            var repository = GetBookingRepositoryForTest();
            var evnt       = await EventRepositoryTest.GetEventForTestAsync();

            var candidate = await candidateRepository.FindByIdAsync(candidateId);

            var result = await repository.CreateFromCandidateAsync(evnt, candidate, placeInQueue);

            var booking = await repository.FindByReferenceAsync(result.Reference);

            Assert.IsNotNull(booking);
            Assert.AreEqual(booking.EventId, evnt.Id);
            Assert.IsTrue(booking.CandidateId.HasValue);
            Assert.AreEqual(booking.CandidateId.Value, candidateId);
            Assert.AreEqual(booking.FirstName, newCandidate.FirstName);
            Assert.AreEqual(booking.LastName, newCandidate.LastName);
            Assert.AreEqual(booking.Email, newCandidate.Email);
            Assert.AreEqual(booking.PhoneNo, newCandidate.PhoneNo);
            Assert.AreEqual(booking.TeamName, newCandidate.TeamName);
            Assert.AreEqual(placeInQueue, booking.QueueNo);
            Assert.AreEqual(String.Empty, booking.SpecialRequest);
            Assert.AreEqual(0.0m, booking.TotalPrice);
        }
        public async Task GivenExistingBooking_WhenUpdatedWithPax_ShouldUpdateBooking()
        {
            var repository = GetBookingRepositoryForTest();
            var evnt       = await EventRepositoryTest.GetEventForTestAsync();

            var booking = await GetNewlyCreatedBookingForTest(evnt, repository);

            var source = new BookingSource
            {
                Reference = booking.Reference,
                Pax       = new List <BookingSource.PaxSource> {
                    GetPaxSourceForTest(), GetPaxSourceForTest(), GetPaxSourceForTest()
                }
            };

            var result = await repository.UpdateAsync(evnt, source);

            Assert.AreEqual(booking.Reference, result.Reference);

            booking = await repository.FindByReferenceAsync(result.Reference);

            var pax = await repository.GetPaxForBookingAsync(booking);

            Assert.AreEqual(3, pax.Length);
        }
        public async Task GivenExistingBooking_WhenUpdatedWithTooManyPax_ShouldReject()
        {
            var repository = GetBookingRepositoryForTest();
            var evnt       = await EventRepositoryTest.GetEventForTestAsync();

            var booking = await GetNewlyCreatedBookingForTest(evnt, repository);

            var pax = new List <BookingSource.PaxSource>();

            for (int i = 0; i < BookingSource.MaximumPaxInBooking + 1; i++)
            {
                pax.Add(GetPaxSourceForTest());
            }

            var source = new BookingSource {
                Reference = booking.Reference, Pax = pax
            };

            await repository.UpdateAsync(evnt, source);
        }
        public async Task GivenBookingCreatedFromCandidate_WhenCandidateDeleted_ShouldRetainBooking()
        {
            var candidate = await BookingCandidateRepositoryTest.GetNewlyCreatedBookingCandidateForTest();

            var repository = GetBookingRepositoryForTest();
            var evnt       = await EventRepositoryTest.GetEventForTestAsync();

            var result = await repository.CreateFromCandidateAsync(evnt, candidate, 1);

            var candidateRepository = BookingCandidateRepositoryTest.CreateBookingCandidateRepositoryForTest();
            await candidateRepository.DeleteAllAsync();

            candidate = await candidateRepository.FindByIdAsync(candidate.Id);

            Assert.IsNull(candidate);

            var booking = await repository.FindByReferenceAsync(result.Reference);

            Assert.IsNotNull(booking);
            Assert.AreEqual(booking.EventId, evnt.Id);
            Assert.IsFalse(booking.CandidateId.HasValue);
        }