コード例 #1
0
        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();
        }
コード例 #2
0
        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");
        }