finished writing unit tests for Quote Controller added unit test for character controller when no character is found for a given valid object id

This commit is contained in:
StevanFreeborn
2022-07-11 12:46:12 -05:00
parent dbed2a0e36
commit c492f57980
4 changed files with 150 additions and 4 deletions
@@ -90,6 +90,30 @@ namespace server.tests.v1.UnitTests
character.Should().BeOfType<Character>();
}
[Fact]
public async Task GetCharacterByIdAsync_ValidCharacterIdForNonExistentCharacter_Returns404StatusCodeWithProblemDetails()
{
var characterId = "62b7d5506c1b407771829926";
_mockRepo
.Setup(repo => repo.GetCharacterByIdAsync(characterId))
.ReturnsAsync(null as Character);
var response = await _controller.GetCharacterByIdAsync(characterId) as ObjectResult;
var details = response.Value;
_mockRepo.Verify(repo => repo.GetCharacterByIdAsync(It.IsAny<string>()), Times.Once());
response.Should().NotBeNull();
response.Should().BeOfType<ObjectResult>();
response.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
details.Should().NotBeNull();
details.Should().BeOfType<ProblemDetails>();
}
[Fact]
public async Task GetCharacterByIdAsync_RepoThrowsException_Returns500StatusCodeWithProblemDetails()
{