public async Task GitUsers_TestAsync() { using (var client = new ClientProvider().Client) { var response = await client.GetAsync("api/github/gitusers"); response.EnsureSuccessStatusCode(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } }
public async Task GitUsers_TestWithTwoResults(string[] users) { using (var client = new ClientProvider().Client) { string param = string.Join("&", users.Select(x => "usernames=" + x)); var response = await client.GetAsync($"api/github/gitusers/?{ param }"); var gitusers = JsonConvert.DeserializeObject <List <Users> >(response.Content.ReadAsStringAsync().Result); Assert.Equal(2, gitusers.Count); } }
public async Task GitUsers_TestInvalidResults(string[] users) { using (var client = new ClientProvider().Client) { string param = string.Join("&", users.Select(x => "usernames=" + x)); var response = await client.GetAsync($"api/github/gitusers/?{ param }"); var gitusers = JsonConvert.DeserializeObject <List <Users> >(response.Content.ReadAsStringAsync().Result); //invaliduser1234 Assert.Equal("invaliduser1234", gitusers[0].User); Assert.Null(gitusers[0].Name); //invaliduser5678 Assert.Equal("invaliduser5678", gitusers[1].User); Assert.Null(gitusers[1].Name); } }
public async Task GitUsers_TestSorting(string[] users) { using (var client = new ClientProvider().Client) { string param = string.Join("&", users.Select(x => "usernames=" + x)); var response = await client.GetAsync($"api/github/gitusers/?{ param }"); var gitusers = JsonConvert.DeserializeObject <List <Users> >(response.Content.ReadAsStringAsync().Result); //Sorted by name //----------------------- //jonsnow1144 - Carl //Names - Jesse Andrews //caged - Justin Palmer //kevinclark - Kevin Clark Assert.Equal("Carl", gitusers[0].Name); Assert.Equal("Jesse Andrews", gitusers[1].Name); Assert.Equal("Justin Palmer", gitusers[2].Name); Assert.Equal("Kevin Clark", gitusers[3].Name); } }