public void DownloadingFromNonExistingDomainThrows() { Stopwatch watch; ILogging logger; StartTest(out watch, out logger); var fileSystem = Environment.FileSystem; var downloadTask = new DownloadTextTask(TaskManager.Token, fileSystem, "http://ggggithub.com/robots.txt"); var exceptionThrown = false; var autoResetEvent = new AutoResetEvent(false); StartTrackTime(watch); downloadTask .Finally((b, exception) => { exceptionThrown = exception != null; autoResetEvent.Set(); }) .Start(); autoResetEvent.WaitOne(Timeout).Should().BeTrue("Finally raised the signal");; StopTrackTimeAndLog(watch, logger); exceptionThrown.Should().BeTrue(); }
public void DownloadingATextFileWorks() { Stopwatch watch; ILogging logger; StartTest(out watch, out logger); var fileSystem = Environment.FileSystem; var gitLfsMd5 = new UriString($"http://localhost:{server.Port}/git-lfs.zip.MD5.txt"); var downloadTask = new DownloadTextTask(TaskManager.Token, fileSystem, gitLfsMd5, TestBasePath); var autoResetEvent = new AutoResetEvent(false); string result = null; StartTrackTime(watch); downloadTask .Finally(r => { result = r; autoResetEvent.Set(); }) .Start(); autoResetEvent.WaitOne(Timeout).Should().BeTrue("Finally raised the signal");; StopTrackTimeAndLog(watch, logger); result.Should().Be("105DF1302560C5F6AA64D1930284C126"); }
public void DownloadingAFileWithHashValidationWorks() { Stopwatch watch; ILogging logger; StartTest(out watch, out logger); var fileSystem = Environment.FileSystem; var gitLfs = new UriString($"http://localhost:{server.Port}/git-lfs.zip"); var gitLfsMd5 = new UriString($"http://localhost:{server.Port}/git-lfs.zip.MD5.txt"); var downloadGitLfsMd5Task = new DownloadTextTask(TaskManager.Token, fileSystem, gitLfsMd5, TestBasePath); var downloadGitLfsTask = new DownloadTask(TaskManager.Token, fileSystem, gitLfs, TestBasePath); var result = true; Exception exception = null; var autoResetEvent = new AutoResetEvent(false); StartTrackTime(watch); downloadGitLfsMd5Task .Then((b, s) => { downloadGitLfsTask.ValidationHash = s; }) .Then(downloadGitLfsTask) .Finally((b, ex) => { result = b; exception = ex; autoResetEvent.Set(); }) .Start(); autoResetEvent.WaitOne(Timeout).Should().BeTrue("Finally raised the signal");; StopTrackTimeAndLog(watch, logger); result.Should().BeTrue(); exception.Should().BeNull(); }