public async Task CreateBooking_Should_ThrowException_WhenCustomerIdIsNull()
 {
     // Arrange
     var clientId   = Guid.NewGuid();
     var customerId = Guid.NewGuid();
     var sut        = new BookingRequestService(repo, customerService);
     var newBooking = new BookingRequest_Create {
         Registration = "EF02VCC"
     };
     // Act & Assert
     await Assert.ThrowsAsync <Exception>(async() => await sut.CreateBooking(newBooking, clientId));
 }
        public async Task ConfirmBooking_Should_SetCancelledToFalse()
        {
            // Arrange
            var clientId   = Guid.NewGuid();
            var customerId = Guid.NewGuid();
            var entity     = await repo.Create(new BookingRequest(), customerId, clientId);

            var sut = new BookingRequestService(repo, null);
            // Act
            await sut.ConfirmBooking(entity.Id, clientId);

            // Assert
            var result = await repo.FindById(entity.Id, clientId);

            Assert.False(result.Cancelled);
        }
        public async Task GetBookingsByCustomer_Should_ReturnSingleCustomer()
        {
            // Arrange
            var clientId    = Guid.NewGuid();
            var customerId1 = Guid.NewGuid();
            var customerId2 = Guid.NewGuid();
            await repo.Create(new BookingRequest(), customerId1, clientId);

            await repo.Create(new BookingRequest(), customerId2, clientId);

            var sut = new BookingRequestService(repo, null);
            // Act
            var result = await sut.GetBookingsByCustomer(customerId1, clientId);

            // Assert
            Assert.True(result.Select(x => x.CustomerId).Distinct().Count() == 1);
        }
        public async Task GetBookings_Should_ReturnListOfBookingRequests()
        {
            // Arrange
            var clientId    = Guid.NewGuid();
            var customerId1 = Guid.NewGuid();
            var customerId2 = Guid.NewGuid();
            await repo.Create(new BookingRequest(), customerId1, clientId);

            await repo.Create(new BookingRequest(), customerId2, clientId);

            var sut = new BookingRequestService(repo, null);
            // Act
            var result = await sut.GetBookings(clientId);

            // Assert
            Assert.IsType <List <BookingRequest> >(result);
        }
        public async Task CreateBooking_Should_IncreaseRowCountByOne()
        {
            // Arrange
            var clientId    = Guid.NewGuid();
            var customerId  = Guid.NewGuid();
            var beforeCount = (await repo.FindAllByCustomer(customerId, clientId)).Count();
            var sut         = new BookingRequestService(repo, customerService);
            var newBooking  = new BookingRequest_Create {
                Registration = "EF02VCC", CustomerId = customerId
            };
            // Act
            await sut.CreateBooking(newBooking, clientId);

            // Assert
            var afterCount = (await repo.FindAllByCustomer(customerId, clientId)).Count();

            Assert.Equal(beforeCount + 1, afterCount);
        }