Visual Studio/C#의 단위 테스트 및 비동기 작업에 익숙하지 않습니다. 이것에 대한 도움을 주시면 감사하겠습니다.csharp의 단위 테스트 비동기 작업
내 주요 클래스
class Foo
{
public async Task<string> GetWebAsync()
{
using (var client = new HttpClient())
{
var response = await client.GetAsync("https://hotmail.com");
return await response.Content.ReadAsStringAsync();
}
}
}
단위 테스트
[TestMethod]
public void TestGet()
{
Foo foo = new Foo();
foo.GetWebAsync().ContinueWith((k) =>
{
Console.Write(k);
Assert.IsNotNull(null, "error");
});
}
'var에 응답 비동기 테스트를 확인 = 클라이언트를 기다리고 있습니다. GetAsync ("https : // hotmail .com "); return response.Content.ReadAsStringAsync();'..... 왜 두 응답을 기다리지 않고 모두 기다려야합니까? – Hackerman
@Hackerman 새로운 코드이고 코드가 완벽하지 않습니다. 답을 수정하는 데 도움주세요. – user2727195
http://codereview.stackexchange.com/ – Hackerman