public async Task Put_UpdateRole_ReturnTrue() { //arrange TagViewModel viewModel = new TagViewModel { TagName = "TagForPostTest", DisplayName = "RoleForPostTest" }; StringContent content = new StringContent(viewModel.ToJsonString(), _encoding, _mediaType); //定义put传递的参数、编码和类型 using var host = await TestHostBuild.GetTestHost().StartAsync(); //启动TestServer var response = await host.GetTestClientWithToken().PostAsync(_testUrl, content); //先添加一个用于更新测试 viewModel.Id = (await response.Content.ReadAsStringAsync()).GetDeserializeObject <ApiResult <ExecuteResult <Tag> > >().data.Result.Id; content = new StringContent(viewModel.ToJsonString(), _encoding, _mediaType); //act response = await host.GetTestClientWithToken().PutAsync(_testUrl, content); var result = (await response.Content.ReadAsStringAsync()).GetDeserializeObject <ApiResult <ExecuteResult> >(); //assert Assert.True(result.data.IsSucceed); //测完把添加的删除 await Delete_Id_ReturnResult(viewModel.Id); }