public async Task CreateIssueAsync_With_An_Exception_Should_Return_StatusCode_500_Test()
            {
                // Arrange

                var issueToCreate = new IssueForCreationDto {
                    IssueDescription = "Test  1"
                };
                const string expectedLog   = "Something went wrong inside CreateIssueAsync action: Some Error";
                const string expectedValue = "Internal server error";

                IssueServiceMock
                .Setup(x => x.CreateIssueAsync(It.IsAny <IssueForCreationDto>()))
                .ThrowsAsync(new Exception("Some Error"));

                // Act

                var result = await ControllerUnderTest.CreateIssueAsync(issueToCreate);

                // Assert

                result.Should().BeOfType <ObjectResult>();
                LoggerMock.Invocations.Count.Should().Be(1);
                LoggerMock.Invocations[0].Arguments[2].ToString().Should().Contain(expectedLog);

                var content = (ObjectResult)result;

                content.StatusCode.Should().Be(500);
                content.Value.Should().Be(expectedValue);
            }
            public async Task CreateIssueAsync_Should_Return_CreatedAtActionResult_With_The_created_Issue_Test()
            {
                // Arrange

                var expectedCreatedAtActionName = nameof(IssueController.IssueByIdAsync);
                var issueToCreate = new IssueForCreationDto {
                    IssueDescription = "Test  1"
                };
                var expectedResult = new IssueDto {
                    Id = 1, IssueDescription = "Test  1"
                };

                IssueServiceMock
                .Setup(x => x.CreateIssueAsync(issueToCreate))
                .ReturnsAsync(expectedResult);

                // Act

                var result = await ControllerUnderTest.CreateIssueAsync(issueToCreate);

                // Assert

                var createdResult = Assert.IsType <CreatedAtRouteResult>(result);

                Assert.Same(expectedResult, createdResult.Value);
                Assert.Equal(expectedCreatedAtActionName, createdResult.RouteName);
                Assert.Equal(expectedResult.Id, createdResult.RouteValues.GetValueOrDefault("id")
                             );
            }
            public async Task CreateIssueAsync_With_Null_IssueForCreationDto_Should_Return_BadRequest_Test()
            {
                // Arrange

                const string expectedLog = "Issue object sent from client is null";

                // Act

                var result = await ControllerUnderTest.CreateIssueAsync(null);

                // Assert

                result.Should().BeOfType <BadRequestObjectResult>();
                LoggerMock.Invocations.Count.Should().Be(1);
                LoggerMock.Invocations[0].Arguments[2].ToString().Should().Contain(expectedLog);
            }
            public async Task CreateIssueAsync_With_Invalid_Id_Should_Return_BadRequestResult_Test()
            {
                // Arrange

                var expectedIssue = new IssueForCreationDto()
                {
                    Id = 1, IssueDescription = "Test 1", DateAdded = DateTimeOffset.Now
                };

                ControllerUnderTest.ModelState.AddModelError("Id", "Some Error");

                // Act

                var result = await ControllerUnderTest.CreateIssueAsync(expectedIssue);

                // Assert

                var badRequestResult = Assert.IsType <BadRequestObjectResult>(result);

                Assert.IsType <SerializableError>(badRequestResult.Value);
            }