public async Task <ActionResult <List <CatsSortedResult> > > GetCatsSortedByOwnerGender() { _logger.LogInformation("Getting cats by owner gender..."); var res = await _petsService.GetCatsByGenderOfOwner(); return(Ok(res)); }
public async Task SuccessfullyCategorizeCatsWhenPeopleApiResponds() { var json = "[{\"name\":\"Bob\",\"gender\":\"Male\",\"age\":23,\"pets\":[{\"name\":\"Garfield\",\"type\":\"Cat\"},{\"name\":\"Fido\",\"type\":\"Dog\"}]},{\"name\":\"Jennifer\",\"gender\":\"Female\",\"age\":18,\"pets\":[{\"name\":\"Garfield\",\"type\":\"Cat\"}]},{\"name\":\"Steve\",\"gender\":\"Male\",\"age\":45,\"pets\":null},{\"name\":\"Fred\",\"gender\":\"Male\",\"age\":40,\"pets\":[{\"name\":\"Tom\",\"type\":\"Cat\"},{\"name\":\"Max\",\"type\":\"Cat\"},{\"name\":\"Sam\",\"type\":\"Dog\"},{\"name\":\"Jim\",\"type\":\"Cat\"}]},{\"name\":\"Samantha\",\"gender\":\"Female\",\"age\":40,\"pets\":[{\"name\":\"Tabby\",\"type\":\"Cat\"}]},{\"name\":\"Alice\",\"gender\":\"Female\",\"age\":64,\"pets\":[{\"name\":\"Simba\",\"type\":\"Cat\"},{\"name\":\"Nemo\",\"type\":\"Fish\"}]}]"; var peopleApiResponse = JsonConvert.DeserializeObject <List <PetsOwner> >(json); _peopleHttpClient.GetPeopleData().Returns(peopleApiResponse); var result = await _petsService.GetCatsByGenderOfOwner(); result[0].OwnerGender.Should().Be(Gender.Male); result[0].PetNames.Should().NotBeEmpty(); result[0].PetNames.Count.Should().Be(4); result[1].OwnerGender.Should().Be(Gender.Female); result[1].PetNames.Should().NotBeEmpty(); result[1].PetNames.Count.Should().Be(3); }