public async Task put_valid_player_returns_no_content(string url) { var generated = DatabaseSeed.GenerateRandomPlayer(); var postContent = new StringContent(JsonConvert.SerializeObject(generated), System.Text.Encoding.UTF8, "application/json"); var postResponse = await client.PostAsync(url, postContent); postResponse.EnsureSuccessStatusCode(); var playerContent = await postResponse.Content.ReadAsStringAsync(); var player = JsonConvert.DeserializeObject <Player>(playerContent); player.Age = DatabaseSeed.GetRandomAge(); var putContent = new StringContent(JsonConvert.SerializeObject(player), System.Text.Encoding.UTF8, "application/json"); var response = await client.PutAsync($"{url}/{player.PlayerId}", putContent); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); }
public async Task <Player> GetPlayerToUpdate() { Player result = await DbContext.Players.FirstOrDefaultAsync(); result.SkillLevel = DatabaseSeed.GetRandomSkillLevel(); result.Age = DatabaseSeed.GetRandomAge(); return(result); }