public async Task Put_ShouldReturnOk_WhenUserIsAdminAndDataIsValid() { await AuthenticateAdminAsync(); var addExercise = new AddExercise { Name = "testExercise", PartOfBody = PartOfBodyId.Chest.ToString() }; var createdExercise = await _client.CreatePostAsync("api/exercises", addExercise); var updateExercise = new UpdateExercise { ExerciseId = createdExercise.Id, Name = createdExercise.Name + "Updated", PartOfBody = createdExercise.PartOfBody }; var response = await _client.PutAsJsonAsync("api/exercises", updateExercise); response.EnsureSuccessStatusCode(); response.StatusCode.ShouldBe(HttpStatusCode.OK); var exerciseResponse = await _client.GetAsync($"api/exercises/{updateExercise.ExerciseId}"); var updatedExercise = await exerciseResponse.Content.ReadAsAsync <ExerciseDto>(); updatedExercise.Name.ShouldBe(updateExercise.Name); }
public async Task <ActionResult> Put([FromBody] UpdateExercise command) { await DispatchAsync(command); _logger.LogInfo($"Exercise with id: {command.ExerciseId} updated."); return(Ok()); }