Created
December 6, 2011 08:36
-
-
Save biac/1437394 to your computer and use it in GitHub Desktop.
FeedReader: みっつめのテスト ~ 同期メソッドみたいに扱える (製品コードではやっちゃダメ)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void ReadAsyncTest3_補足_GetResultで同期メソッドとして扱う() | |
{ | |
Stopwatch sw = Stopwatch.StartNew(); | |
//FeedData fd = (new FeedReader()).ReadAsync(RssUrl).Result; // こうすれば同期メソッドと同じように使える | |
FeedData fd = (new FeedReader()).ReadAsync(RssUrl).GetAwaiter().GetResult(); // さらにこうすれば非同期実行側の例外もそのまま出てくる | |
sw.Stop(); | |
Assert.IsTrue(100L < sw.ElapsedMilliseconds); //実際には 500~1000mSec 程度掛かっている | |
StringAssert.StartsWith(fd.Title, "Amazon.co.jp: 本"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment