public void PetsController_GetAllPetsByOwnerGender_Test() { var list = new List <OwnerGenderPets>(); list.Add(new OwnerGenderPets { Gender = "M", PetNames = new List <string> { "abc", "def", "ghi" } }); list.Add(new OwnerGenderPets { Gender = "F", PetNames = new List <string> { "jkl", "mno", "pqr" } }); petOwnerService.GetAllPetsByOwnerGenderAsync(PetType.Cat).Returns(list); _petsController = new PetsController(petOwnerService); var result = _petsController.GetAllPetsByOwnerGender(PetType.Cat).Result; Assert.IsType <OkObjectResult>(result); var value = ((OkObjectResult)result).Value; Assert.Equal(2, (value as List <OwnerGenderPets>).Count); }