public async Task GetDiscountAsync__An_unexpected_internal_error_occurred__Should_throw_Exception()
        {
            _discountDbServiceMock.Setup(x => x.GetAsync(It.IsAny <string>())).ThrowsAsync(new Exception());
            var controller = new DiscountsController(_discountDbServiceMock.Object, _logger, _mapperMock.Object);

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

            await result.Should().ThrowExactlyAsync <Exception>();
        }
        public async Task GetDiscountAsync__Argument_id_is_null_or_empty__Should_return_400BadRequest_response([Values(null, "")] string id)
        {
            _discountDbServiceMock.Setup(x => x.GetAsync(id)).ThrowsAsync(new ArgumentException());
            var controller = new DiscountsController(_discountDbServiceMock.Object, _logger, _mapperMock.Object);

            var result = await controller.GetDiscountAsync(id);

            (result as ObjectResult).StatusCode.Should().Be(400);
            ((result as ObjectResult).Value as ResponseWrapper).Error.Should().NotBeNull();
        }
        public async Task GetDiscountAsync__Element_not_found__Should_return_404NotFound_response_with_error()
        {
            _discountDbServiceMock.Setup(x => x.GetAsync(It.IsNotNull <string>())).ThrowsAsync(new InvalidOperationException());
            var controller = new DiscountsController(_discountDbServiceMock.Object, _logger, _mapperMock.Object);

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

            (result as ObjectResult).StatusCode.Should().Be(404);
            ((result as ObjectResult).Value as ResponseWrapper).Error.Should().NotBeNull();
        }
        public async Task GetDiscountAsync__An_internal_error_reffered_to_the_database_occurred__Should_throw_InternalDbServiceException()
        {
            // Example of these errors: database does not exist, table does not exist etc.

            _discountDbServiceMock.Setup(x => x.GetAsync(It.IsAny <string>())).ThrowsAsync(new InternalDbServiceException());
            var controller = new DiscountsController(_discountDbServiceMock.Object, _logger, _mapperMock.Object);

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

            await result.Should().ThrowExactlyAsync <InternalDbServiceException>();
        }
        public async Task GetDiscountAsync__Data_retrieve_succeeded__Should_return_200Ok_response_with_data()
        {
            string id = "15891fb0-faec-43c6-9e83-04a4a17c3660";

            _discountDbServiceMock.Setup(x => x.GetAsync(It.IsNotNull <string>())).ReturnsAsync(_validDiscount);
            _mapperMock.Setup(x => x.Map <DiscountDto>(It.IsNotNull <Discount>())).Returns(new DiscountDto {
                Id = id, Description = "new mapped discount"
            });
            var controller = new DiscountsController(_discountDbServiceMock.Object, _logger, _mapperMock.Object);

            var result = await controller.GetDiscountAsync(id);

            (result as ObjectResult).StatusCode.Should().Be(200);
            ((result as ObjectResult).Value as ResponseWrapper).Data.Should().NotBeNull();
        }