public async Task GivenExistingBooking_WhenDeleted_ShouldLeaveRecordInDeletedBookings()
        {
            var repository = BookingRepositoryTest.GetBookingRepositoryForTest();
            var cruise     = await CruiseRepositoryTest.GetCruiseForTestAsync();

            var booking = await BookingRepositoryTest.GetNewlyCreatedBookingForTestAsync(cruise, repository);

            var           paymentRepository = AecPaymentRepositoryTest.GetPaymentRepositoryForTest();
            const decimal amountPaid        = 10m;
            await paymentRepository.CreateAsync(booking, amountPaid);

            await repository.DeleteAsync(booking);

            var deletedBookingRepository = GetDeletedBookingRepositoryForTest();
            var deleted = (await deletedBookingRepository.FindByReferenceAsync(booking.Reference)).FirstOrDefault();

            Assert.IsNotNull(deleted);
            Assert.AreEqual(booking.CruiseId, deleted.CruiseId);
            Assert.AreEqual(booking.Reference, deleted.Reference);
            Assert.AreEqual(booking.FirstName, deleted.FirstName);
            Assert.AreEqual(booking.LastName, deleted.LastName);
            Assert.AreEqual(booking.Email, deleted.Email);
            Assert.AreEqual(booking.PhoneNo, deleted.PhoneNo);
            Assert.AreEqual(booking.TotalPrice, deleted.TotalPrice);
            Assert.AreEqual(amountPaid, deleted.AmountPaid);
        }
        public async Task GivenExistingBooking_WhenDeleted_ShouldCeaseToExist()
        {
            var repository = BookingRepositoryTest.GetBookingRepositoryForTest();
            var cruise     = await CruiseRepositoryTest.GetCruiseForTestAsync();

            var booking = await BookingRepositoryTest.GetNewlyCreatedBookingForTestAsync(cruise, repository);

            Assert.AreNotEqual(Guid.Empty, booking.Id);
            await repository.DeleteAsync(booking);

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

            Assert.IsNull(deletedBooking);

            deletedBooking = await repository.FindByIdAsync(booking.Id);

            Assert.IsNull(deletedBooking);
        }
Ejemplo n.º 3
0
        public async Task GivenBooking_WhenPaymentsRegistered_ShouldCalculateCorrectSummary()
        {
            var booking = await BookingRepositoryTest.GetNewlyCreatedBookingForTestAsync();

            var repository = GetPaymentRepositoryForTest();

            decimal amount1 = 409.27m, amount2 = 15000m, amount3 = -927.44m;

            await repository.CreateAsync(booking, amount1);

            await repository.CreateAsync(booking, amount2);

            await repository.CreateAsync(booking, amount3);

            PaymentSummary summary = await repository.GetSumOfPaymentsByBookingAsync(booking);

            Assert.AreEqual(amount1 + amount2 + amount3, summary.Total);
            Assert.AreNotEqual(DateTime.MinValue, summary.Latest);
        }