public ActionResult <PetsClassified> Get() { PetsClassified petsClassified = _petService.GetPetsClassified(); if (petsClassified == null) { return(NotFound()); } return(Ok(petsClassified)); }
public void Get_RecieveDataTest() { PetsClassified objPetsClassified = new PetsClassified { MalePets = new List <string> { "ABC", "DEF" }, FemalePets = new List <string> { "ABC1", "DEF1", "GHI1" }, }; Mock petservicMock = new Mock <IPetsService>(); petservicMock.As <IPetsService>().Setup(x => x.GetPetsClassified()).Returns(objPetsClassified); PetController controller = new PetController(petservicMock.Object as IPetsService); var result = controller.Get(); Assert.IsTrue(((OwnerPets.Services.PetsClassified)((Microsoft.AspNetCore.Mvc.ObjectResult)result.Result).Value).FemalePets.Count == 3); }