Beispiel #1
0
        public void CanDownloadFromMultipleMirrorsAsync()
        {
            var mirrorSelector = SetupMultiMirrorSelector();
            var downloader     = SetupDefaultDownloader();
            var mDownloader    = new MultiMirrorFileDownloader(downloader, mirrorSelector);

            Func <Task> act =
                () => mDownloader.DownloadAsync(new MultiMirrorFileDownloadSpec("a", "C:\\b".ToAbsoluteFilePath()));

            act.ShouldThrow <HostListExhausted>();
            A.CallTo(() => mirrorSelector.Failure(httpHost1))
            .MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => mirrorSelector.Failure(httpHost2))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Beispiel #2
0
        public async Task SuccessDownloadAsyncShouldBeRegistered()
        {
            var mirrorSelector = SetupDefaultMirrorSelector();
            var downloader     = A.Fake <IFileDownloader>();
            var mDownloader    = new MultiMirrorFileDownloader(downloader, mirrorSelector);

            await mDownloader.DownloadAsync(new MultiMirrorFileDownloadSpec("a", @"C:\temp\a".ToAbsoluteFilePath()));

            A.CallTo(() => mirrorSelector.GetHost())
            .MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => downloader.DownloadAsync(new Uri("http://testhost/a"), @"C:\temp\a".ToAbsoluteFilePath()))
            .MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => mirrorSelector.Success(httpTesthost))
            .MustHaveHappened(Repeated.Exactly.Once);
        }