public List <PetsResult> GetPetsResultList(PersonListType listType) { switch (listType) { case PersonListType.AllGoodData: return(new List <PetsResult> { new PetsResult { OwnerGender = "Male", PetNames = new List <string> { "Mialo", "Milon", "Oscar", "Smokey", "Tina" } }, new PetsResult { OwnerGender = "Female", PetNames = new List <string> { "Lucy", "Milo" } } }); case PersonListType.PetNamesWithSpaces: return(new List <PetsResult> { new PetsResult { OwnerGender = "Male", PetNames = new List <string> { "Ma Mialo", "Ma Milon", "Oscar", "Smokey", "Tina" } }, new PetsResult { OwnerGender = "Female", PetNames = new List <string> { "Lucy", "Milo Me" } } }); default: return(null); } }
public async Task <SearchContainer <PersonResult> > GetPersonListAsync(PersonListType type, int page = 0, CancellationToken cancellationToken = default(CancellationToken)) { RestRequest req; switch (type) { case PersonListType.Popular: req = _client.Create("person/popular"); break; default: throw new ArgumentOutOfRangeException(nameof(type)); } if (page >= 1) { req.AddParameter("page", page.ToString()); } // TODO: Dateformat? //req.DateFormat = "yyyy-MM-dd"; req.AddParameter("language", "zh-CN"); RestResponse <SearchContainer <PersonResult> > resp = await req.ExecuteGet <SearchContainer <PersonResult> >(cancellationToken).ConfigureAwait(false); return(resp); }
public SearchContainer <PersonResult> GetPersonList(PersonListType type, int page = 0) { RestRequest req; switch (type) { case PersonListType.Popular: req = new RestRequest("person/popular"); break; default: throw new ArgumentOutOfRangeException("type"); } if (page >= 1) { req.AddParameter("page", page.ToString()); } req.DateFormat = "yyyy-MM-dd"; IRestResponse <SearchContainer <PersonResult> > resp = _client.Get <SearchContainer <PersonResult> >(req); return(resp.Data); }
private List <PetsResult> GetResultsForPersonListType(PersonListType listType) { List <PetsResult> petsResults = null; var result = (OkObjectResult)GetResultForPersonPets(listType); if (result != null) { petsResults = (List <PetsResult>)result.Value; } return(petsResults); }
private IActionResult GetResultForPersonPets(PersonListType listType) { var persons = _personListFactory.GetPersonList(listType); var peopleApiClientMock = new Mock <IPeopleApiClient>(); peopleApiClientMock.Setup(apiClient => apiClient.GetPersonData()).Returns(Task.FromResult(persons)); var peopleServiceLoggerMock = new Mock <ILogger <PeopleService> >(); var peopleService = new PeopleService(peopleApiClientMock.Object, new ValidatorService(), peopleServiceLoggerMock.Object); var controller = new PersonPetsController(_loggerMock.Object, peopleService); return(controller.GetPetsData(string.Empty, "cat").Result); }
public Task <SearchContainer <PersonResult> > GetPersonListAsync(PersonListType type, int page = 0, CancellationToken cancellationToken = default) { base.Track(); return(tmdbClient.GetPersonListAsync(type, page, cancellationToken)); }
public List <Person> GetPersonList(PersonListType listType) { switch (listType) { case PersonListType.AllGoodData: return(new List <Person> { new Person { Age = 25, Gender = "Male", Name = "Aajay", Pets = new List <Pet> { new Pet { Name = "Tina", Species = "Cat" }, new Pet { Name = "Max", Species = "Dog" }, new Pet { Name = "Smokey", Species = "Cat" }, new Pet { Name = "Oscar", Species = "Cat" }, new Pet { Name = "Fishy", Species = "Fish" }, } }, new Person { Age = 36, Gender = "Female", Name = "Shasha", Pets = new List <Pet> { new Pet { Name = "Milo", Species = "Cat" }, new Pet { Name = "Twister", Species = "Python" }, } }, new Person { Age = 46, Gender = "Female", Name = "Shashanti", Pets = new List <Pet> { new Pet { Name = "Rocky", Species = "Dog" }, new Pet { Name = "Lucy", Species = "Cat" }, } }, new Person { Age = 36, Gender = "Male", Name = "Amit", Pets = new List <Pet> { new Pet { Name = "Mialo", Species = "Cat" }, new Pet { Name = "Milon", Species = "Cat" }, } }, }); case PersonListType.EmptyList: return(new List <Person>()); case PersonListType.IrregularFontCase: return(new List <Person> { new Person { Age = 25, Gender = "mAlE", Name = "Ajay", Pets = new List <Pet> { new Pet { Name = "tINa", Species = "Cat" }, } } }); case PersonListType.MissingPetName: return(new List <Person> { new Person { Age = 45, Gender = "Female", Name = "Sasha", Pets = new List <Pet> { new Pet { Name = "Caty", Species = "Dog" }, new Pet { Name = "", Species = "Cat" }, } } }); case PersonListType.AgeLessThanOne: return(new List <Person> { new Person { Age = 45, Gender = "Female", Name = "Sasha", Pets = new List <Pet> { new Pet { Name = "Caty", Species = "Dog" }, new Pet { Name = "", Species = "Cat" }, } }, new Person { Age = 0, Gender = "Male", Name = "Sain", Pets = new List <Pet> { new Pet { Name = "Pssy", Species = "Dog" }, } } }); case PersonListType.InvalidGender: return(new List <Person> { new Person { Age = 45, Gender = "Xyz", Name = "Sasha", Pets = new List <Pet> { new Pet { Name = "Caty", Species = "Dog" }, new Pet { Name = "", Species = "Cat" }, } } }); case PersonListType.MissingPetType: return(new List <Person> { new Person { Age = 45, Gender = "Male", Name = "Sashan", Pets = new List <Pet> { new Pet { Name = "Caty", Species = "" }, new Pet { Name = "", Species = "Cat" }, } } }); case PersonListType.DuplicatePetNames: return(new List <Person> { new Person { Age = 45, Gender = "Male", Name = "Sashan", Pets = new List <Pet> { new Pet { Name = "Timmy", Species = "Cat" }, new Pet { Name = "Timmy", Species = "Cat" }, } }, new Person { Age = 45, Gender = "Female", Name = "Silly", Pets = new List <Pet> { new Pet { Name = "Timmy", Species = "Cat" }, } } }); case PersonListType.PetNamesWithSpaces: return(new List <Person> { new Person { Age = 25, Gender = "Male", Name = "Aajay", Pets = new List <Pet> { new Pet { Name = "Tina", Species = "Cat" }, new Pet { Name = "Max", Species = "Dog" }, new Pet { Name = "Smokey", Species = "Cat" }, new Pet { Name = "Oscar", Species = "Cat" }, new Pet { Name = "Fishy", Species = "Fish" }, } }, new Person { Age = 36, Gender = "Female", Name = "Shasha", Pets = new List <Pet> { new Pet { Name = "Milo Me", Species = "Cat" }, new Pet { Name = "Twister", Species = "Python" }, } }, new Person { Age = 46, Gender = "Female", Name = "Shashanti", Pets = new List <Pet> { new Pet { Name = "Rocky", Species = "Dog" }, new Pet { Name = "Lucy", Species = "Cat" }, } }, new Person { Age = 36, Gender = "Male", Name = "Amit", Pets = new List <Pet> { new Pet { Name = "Ma Mialo", Species = "Cat" }, new Pet { Name = "Ma Milon", Species = "Cat" }, } }, }); case PersonListType.IrregularGenderCase: return(new List <Person> { new Person { Age = 25, Gender = "Male", Name = "Aajay", Pets = new List <Pet> { new Pet { Name = "Tina", Species = "Cat" }, new Pet { Name = "Max", Species = "Dog" }, new Pet { Name = "Smokey", Species = "Cat" }, new Pet { Name = "Oscar", Species = "Cat" }, new Pet { Name = "Fishy", Species = "Fish" }, } }, new Person { Age = 36, Gender = "Female", Name = "Shasha", Pets = new List <Pet> { new Pet { Name = "Milo", Species = "Cat" }, new Pet { Name = "Twister", Species = "Python" }, } }, new Person { Age = 46, Gender = "female", Name = "Shashanti", Pets = new List <Pet> { new Pet { Name = "Rocky", Species = "Dog" }, } }, new Person { Age = 36, Gender = "male", Name = "Amit", Pets = new List <Pet> { new Pet { Name = "Mialo", Species = "Cat" }, } }, new Person { Age = 46, Gender = "feMale", Name = "Shashanti", Pets = new List <Pet> { new Pet { Name = "Lucy", Species = "Cat" }, } }, new Person { Age = 36, Gender = "mALE", Name = "Amit", Pets = new List <Pet> { new Pet { Name = "Milon", Species = "Cat" }, } }, }); case PersonListType.NoPets: return(new List <Person> { new Person { Age = 45, Gender = "Male", Name = "Sasha", Pets = new List <Pet> { new Pet { Name = "Caty", Species = "Dog" }, new Pet { Name = "Oscar", Species = "Cat" }, } }, new Person { Age = 50, Gender = "Male", Name = "Sushant", Pets = null } }); default: return(null); } }