UWP 非同期メソッドのユニットテスト

非同期メソッドの単体テストを行うには、async Task とすればよい。

https://stackoverflow.com/questions/2060692/how-does-one-test-asynccode-using-mstest

理屈はいかに詳しい。今度しっかり読む。

https://msdn.microsoft.com/ja-jp/magazine/dn818493.aspx

  1. [TestMethod]
  2. public async Task AsyncMethodUnitTest()
  3. {
  4. var uri = new System.Uri("ms-appx:///Assets/.passwords.txt");
  5. var file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);
  6. string text = await Windows.Storage.FileIO.ReadTextAsync(file);
  7.  
  8. Debug.WriteLine(text);
  9. }

Follow me!

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です