public void DownloadFileAsync_should_be_callable_indirectly() { using (new IndirectionsContext()) { // Arrange var called = false; var notCalled = true; var handler = default(AsyncCompletedEventHandler); handler = (sender, e) => called = true; PULWebClient.AddDownloadFileCompletedAsyncCompletedEventHandler().Body = (@this, value) => handler += value; PULWebClient.RemoveDownloadFileCompletedAsyncCompletedEventHandler().Body = (@this, value) => handler -= value; PULWebClient.DownloadFileAsyncUri().Body = (@this, address) => { var e = new AsyncCompletedEventArgs(null, false, null); handler(@this, e); }; // Act var client = new ULWebClient(); client.DownloadFileAsync(new Uri("http://google.co.jp/")); client.DownloadFileCompleted += (sender, e) => notCalled = false; // Assert Assert.IsTrue(called); Assert.IsTrue(notCalled); } }
static void Main(string[] args) { //Console.WriteLine(LifeInfo.IsNowLunchBreak() ? "お昼休みなう!" : "お仕事なう・・・"); var client = new ULWebClient(); client.DownloadFileCompleted += client_DownloadFileCompleted; client.DownloadFileAsync(new Uri("http://google.co.jp/")); Console.ReadLine(); }