public async Task GetCustomerTicket__Argument_customerId_is_null_or_empty__Should_return_400BadRequest_response([Values(null, "")] string customerId)
        {
            var controller = new TicketsController(_ticketDbServiceMock.Object, _logger, _mapperMock.Object);

            var result = await controller.GetCustomerTicketsAsync(customerId);

            (result as ObjectResult).StatusCode.Should().Be(400);
            ((result as ObjectResult).Value as ResponseWrapper).Error.Should().NotBeEquivalentTo(new ApiError());
        }
        public async Task GetCustomerTickets__An_unexpected_internal_error_occurred__Should_throw_Exception()
        {
            _ticketDbServiceMock.Setup(x => x.GetByAsync(It.IsAny <Expression <Func <Ticket, bool> > >())).ThrowsAsync(new Exception());
            var controller = new TicketsController(_ticketDbServiceMock.Object, _logger, _mapperMock.Object);

            Func <Task> result = async() => await controller.GetCustomerTicketsAsync("1");

            await result.Should().ThrowExactlyAsync <Exception>();
        }
        public async Task GetCustomerTickets__At_least_one_ticket_found__Should_return_200OK_response_with_not_empty_IEnumerable()
        {
            _ticketDbServiceMock.Setup(x => x.GetByAsync(It.IsAny <Expression <Func <Ticket, bool> > >())).ReturnsAsync(new Ticket[] { _validTicket }.AsEnumerable());
            _mapperMock.Setup(x => x.Map <IEnumerable <TicketDto> >(It.IsNotNull <IEnumerable <Ticket> >())).Returns(new TicketDto[] { _validTicketDto }.AsEnumerable());
            var controller = new TicketsController(_ticketDbServiceMock.Object, _logger, _mapperMock.Object);

            var result = await controller.GetCustomerTicketsAsync("1");

            (result as ObjectResult).StatusCode.Should().Be(200);
            (((result as ObjectResult).Value as ResponseWrapper).Data as IEnumerable <TicketDto>).Should().NotBeEmpty();
        }
        public async Task GetCustomerTickets__An_internal_error_reffered_to_the_database_occurred__Should_throw_InternalDbServiceException()
        {
            // Example of these errors: database does not exist, table does not exist etc.

            _ticketDbServiceMock.Setup(x => x.GetByAsync(It.IsAny <Expression <Func <Ticket, bool> > >())).ThrowsAsync(new InternalDbServiceException());
            var controller = new TicketsController(_ticketDbServiceMock.Object, _logger, _mapperMock.Object);

            Func <Task> result = async() => await controller.GetCustomerTicketsAsync("1");

            await result.Should().ThrowExactlyAsync <InternalDbServiceException>();
        }
        public async Task GetCustomerTickets__Customer_not_found__Should_return_404NotFound_response()
        {
            // The customer must have at least one ticket because it is created if it has ordered at least one ticket
            _ticketDbServiceMock.Setup(x => x.GetByAsync(It.IsAny <Expression <Func <Ticket, bool> > >())).ReturnsAsync(Enumerable.Empty <Ticket>());
            _mapperMock.Setup(x => x.Map <IEnumerable <TicketDto> >(It.IsNotNull <IEnumerable <Ticket> >())).Returns(Enumerable.Empty <TicketDto>());
            var controller = new TicketsController(_ticketDbServiceMock.Object, _logger, _mapperMock.Object);

            var result = await controller.GetCustomerTicketsAsync("1");

            (result as ObjectResult).StatusCode.Should().Be(404);
            ((result as ObjectResult).Value as ResponseWrapper).Error.Should().NotBeEquivalentTo(new ApiError());
        }