public async Task ArtistsCollection_PostNew_StatusCreated() { HttpResponseMessage response = await HttpClient.PostAsync("/artists", new JsonContent(@"{ ""name"": ""Fred"", start_date: ""1990-01-01"" }")); ResponseAssert.Success(response); Assert.Equal(HttpStatusCode.Created, response.StatusCode); }
public async Task ArtistTracks_Post_NewIdentifier() { HttpResponseMessage response1 = await HttpClient.PostAsJsonAsync("/artists/3/tracks", new { title = "My new track" }); ResponseAssert.Success(response1); string json1 = await response1.Content.ReadAsStringAsync(); dynamic obj1 = JsonConvert.DeserializeObject(json1); Assert.True(obj1.identifier > 0); string trackUrl = "/artists/3/tracks/" + obj1.identifier; HttpResponseMessage response2 = await HttpClient.PutAsJsonAsync(trackUrl, new { title = "My edited track" }); ResponseAssert.Success(response2); var track = await GetDynamicObject(trackUrl); Assert.Equal("My edited track", (string)track.title); }
public async Task AddFixtures_Success() { HttpResponseMessage response = await _client.PostAsync("/teams/1/fixtures", new StringContent(@"[ { vs_team: { id: 2 }, home: true, goals: [ ] } ]")); ResponseAssert.Success(response); }
public async Task ArtistNameScalar_Get_Correct() { HttpResponseMessage response = await HttpClient.GetAsync("/artists/1/name"); ResponseAssert.Success(response); string responseStr = await response.Content.ReadAsStringAsync(); Assert.Equal("\"Eminem\"", responseStr); }
public async Task ArtistsCollection_Get_SuccessAndDeserialises() { HttpResponseMessage response = await HttpClient.GetAsync("/artists"); ResponseAssert.Success(response); string json = await response.Content.ReadAsStringAsync(); var arr = JsonConvert.DeserializeObject <RestItemData[]>(json); }
public async Task RootDirectory_Options_SuccessAndDeserialises() { HttpResponseMessage response = await HttpClient.SendAsync(new HttpRequestMessage(HttpMethod.Options, "/")); ResponseAssert.Success(response); string json = await response.Content.ReadAsStringAsync(); var options = JsonConvert.DeserializeObject <Options>(json); }
public async Task ArtistItem_Get_Deserialises() { HttpResponseMessage response = await HttpClient.GetAsync("/artists/1"); ResponseAssert.Success(response); string json = await response.Content.ReadAsStringAsync(); object obj = JsonConvert.DeserializeObject(json); }
public async Task CalculateLeaguePoints_Success() { HttpResponseMessage response = await _client.GetAsync("/leagues/premierleague/teams?sort=points+desc&limit=1"); ResponseAssert.Success(response); string str = await response.Content.ReadAsStringAsync(); var arr = JsonConvert.DeserializeObject <object[]>(str); Assert.Single(arr); }
private async Task <dynamic> GetDynamicObject(string requestUri) { HttpResponseMessage response = await HttpClient.GetAsync(requestUri); string json = await response.Content.ReadAsStringAsync(); ResponseAssert.Success(response); dynamic obj = JsonConvert.DeserializeObject(json); return(obj); }
public async Task ArtistsCollection_Add_Successful() { var content = new JsonContent(new { id = 10, name = "Haken" }); HttpResponseMessage postResponse = await HttpClient.PostAsync("/artists", content); ResponseAssert.Success(postResponse); }
public async Task RootDirectory_Get_ContainsArtistsCollection() { HttpResponseMessage response = await HttpClient.GetAsync("/"); ResponseAssert.Success(response); string json = await response.Content.ReadAsStringAsync(); var arr = JsonConvert.DeserializeObject <RestItemData[]>(json); Assert.Equal("artists", arr[0]["name"]); Assert.Equal("collection", arr[0]["type"]); }
public async Task ArtistName_Update_GetIsSame() { HttpResponseMessage response1 = await HttpClient.PutAsync("/artists/2/name", new JsonContent(@"""Bob""")); ResponseAssert.Success(response1); HttpResponseMessage response2 = await HttpClient.GetAsync("/artists/2/name"); ResponseAssert.Success(response2); string json = await response2.Content.ReadAsStringAsync(); Assert.Equal("\"Bob\"", json); }
public async Task CorsHeaders_Send_CorsResponse() { var response = await HttpClient.SendAsync(new HttpRequestMessage(HttpMethod.Options, "/") { Headers = { { "Access-Control-Request-Headers", "content-type" }, { "Access-Control-Request-Method", "GET" }, { "Origin", "https://example.com" } } }); ResponseAssert.Success(response); }
public async Task PlayersCollection_PageSize1_NextInLinkHeader() { HttpResponseMessage response = await _client.GetAsync("/players?size=1&fields=name"); ResponseAssert.Success(response); IEnumerable <string> linkHeaders = response.Headers.GetValues("Link"); Assert.Single(linkHeaders); string linkHeaderValue = response.Headers.GetValues("Link").Single(); Assert.Contains("next", linkHeaderValue); }
public async Task ArtistsCollection_GetWithFields_DeserialisesAndCorrect() { HttpResponseMessage response = await HttpClient.GetAsync("/artists?fields=start_date,name"); ResponseAssert.Success(response); string json = await response.Content.ReadAsStringAsync(); dynamic obj = JsonConvert.DeserializeObject(json); string name = obj[0].name; Assert.Equal("Eminem", name); }
public async Task ArtistsCollection_FilterAboveID_Deserialises() { HttpResponseMessage response = await HttpClient.GetAsync("/artists?fields=name&where=id>2"); ResponseAssert.Success(response); string json = await response.Content.ReadAsStringAsync(); dynamic obj = JsonConvert.DeserializeObject(json); string name = obj[0].name; Assert.Equal("Periphery", name); }
public async Task ArtistsCollection_SortByDate_Deserialises() { HttpResponseMessage response = await HttpClient.GetAsync("/artists?fields=id,name&sort=start_date"); ResponseAssert.Success(response); string json = await response.Content.ReadAsStringAsync(); dynamic obj = JsonConvert.DeserializeObject(json); string name = obj[0].name; Assert.Equal("Infected Mushroom", name); }
public async Task ArtistItem_UpdateName_GetIsSame() { HttpResponseMessage response1 = await HttpClient.PutAsync("/artists/2", new JsonContent(@"{ ""name"": ""Bill"" }")); ResponseAssert.Success(response1); HttpResponseMessage response2 = await HttpClient.GetAsync("/artists/2"); ResponseAssert.Success(response2); string json = await response2.Content.ReadAsStringAsync(); dynamic obj = JsonConvert.DeserializeObject(json); Assert.Equal("Bill", obj.name.ToString()); }
public async Task ArtistsCollection_Options_DeserialisesAndCorrect() { HttpResponseMessage response = await HttpClient.SendAsync(new HttpRequestMessage(HttpMethod.Options, "/artists")); ResponseAssert.Success(response); string json = await response.Content.ReadAsStringAsync(); dynamic obj = JsonConvert.DeserializeObject(json); Assert.NotNull(obj); string description = obj.description; Assert.NotNull(description); }
public async Task ArtistsCollection_GetWithFields_DeserialisesAndCorrect() { HttpResponseMessage response = await HttpClient.GetAsync("/artists?fields=id,name"); ResponseAssert.Success(response); string json = await response.Content.ReadAsStringAsync(); dynamic obj = JsonConvert.DeserializeObject(json); Assert.NotNull(obj); string name = obj[0].name; Assert.Equal(TestRepositories.ArtistName, name); }
public async Task Tracks_GetIDsWhereLiked_AllOdd() { HttpResponseMessage response = await HttpClient.GetAsync("/tracks?fields=id&liked=true&where=id<=10"); ResponseAssert.Success(response); string json = await response.Content.ReadAsStringAsync(); var objs = JsonConvert.DeserializeObject <List <dynamic> >(json); Assert.True(objs.Any()); foreach (dynamic obj in objs) { int id = obj.id; Assert.Equal(1, id % 2); // weird bodge, in db all my likes are odd numbers } }
public async Task ArtistsCollection_Get_StatusOK() { HttpResponseMessage response = await HttpClient.GetAsync("/tracks"); ResponseAssert.Success(response); }
public async Task ArtistsCollection_Delete_Successful() { HttpResponseMessage deleteResponse = await HttpClient.DeleteAsync("/artists/123"); ResponseAssert.Success(deleteResponse); }
public async Task HomeDirectory_Get_StatusOK() { HttpResponseMessage response = await HttpClient.GetAsync("/"); ResponseAssert.Success(response); }
public async Task Item_GetWithComplexField_StatusOK() { HttpResponseMessage response = await HttpClient.GetAsync("/tracks/1?fields=id,title,complex"); ResponseAssert.Success(response); }
public async Task Scalar_GetComplexField_StatusOK() { HttpResponseMessage response = await HttpClient.GetAsync("/tracks/1/complex"); ResponseAssert.Success(response); }
public async Task CalculateLeaguePosition_Success() { HttpResponseMessage response = await _client.GetAsync("/leagues/premierleague/teams/by_position/1/name"); ResponseAssert.Success(response); }