public async void GetAllPeopleRoute_Test() { var person1 = CreatePerson(); var person2 = CreatePerson(); var personList = new List <Person>() { person1, person2 }; _personRepository.Setup(x => x.All()).ReturnsAsync(personList); var personController = new PersonController(_personRepository.Object, _mapper, _emailHelper.Object, _tokenClass.Object); // Act var result = await personController.GetAllPeopleAsync(); var okResult = result as OkObjectResult; var returnedPeoplejson = okResult.Value as string; var returnedPeople = JsonSerializer.Deserialize <List <PersonDto> >(returnedPeoplejson); // Assert Assert.True(okResult != null); Assert.True(returnedPeople.Count == 2); Assert.Equal(200, okResult.StatusCode); }