diff --git a/server.tests/controllers/CharactersControllerTests.cs b/server.tests/controllers/CharactersControllerTests.cs index 9de3356..a2b4a44 100644 --- a/server.tests/controllers/CharactersControllerTests.cs +++ b/server.tests/controllers/CharactersControllerTests.cs @@ -36,5 +36,43 @@ namespace tests.controllers Assert.Equal(HttpStatusCode.OK, (HttpStatusCode)result.StatusCode); Assert.Empty(data); } + + [Fact] + public async Task GetCharactersAsync_NoFilterParamsWithCharacters_Returns200StatusWithCharactersCollection() + { + var filter = new CharacterFilter(); + + var character = new Character + { + Id = "", + FirstName = "Jason", + LastName = "Gideon", + ActorFirstName = "Mandy", + ActorLastName = "Patinkin", + Seasons = new int[] {1,2,3,10,15}, + FirstEpisode = "Extreme Aggressor", + LastEpisode = "In Name and Blood", + Image = "https://criminalmindsapi.stevanfreeborn.com/characters/jason-gideon.png", + Bio = "Jason Gideon was a criminal profiler, formerly the Senior Supervisory Special Agent of the FBI's Behavioral Analysis Unit. At the beginning of Season Three, Gideon abruptly retired from the BAU due to emotional issues brought on by the murder of his girlfriend. His position is now held by his former partner and best friend David Rossi, who has held it to this day. In the Season Ten episode \"Nelson's Sparrow\", he was murdered by Donnie Mallick.", + }; + + var characters = new List + { + character + }; + + _mockRepo + .Setup(repo => repo.GetCharactersAsync(filter)) + .ReturnsAsync(characters); + + var result = await _controller.GetCharactersAsync(filter) as ObjectResult; + var data = result?.Value as List; + + _mockRepo.Verify(repo => repo.GetCharactersAsync(It.IsAny()), Times.Once()); + Assert.IsType(result); + Assert.IsType>(data); + Assert.Equal(HttpStatusCode.OK, (HttpStatusCode)result.StatusCode); + Assert.Single(data); + } } }