示例#1
0
        public void DownloadFailsWhenVerificationFails()
        {
            var mirrorSelector = SetupMultiMirrorSelector();
            var downloader     = A.Fake <IFileDownloader>();
            var mDownloader    = new MultiMirrorFileDownloader(downloader, mirrorSelector);

            Action act =
                () =>
                mDownloader.Download(new MultiMirrorFileDownloadSpec("a", "C:\\b".ToAbsoluteFilePath(), f => false));

            act.ShouldThrow <HostListExhausted>();
        }
示例#2
0
        public void CanDownloadFromMultipleMirrors()
        {
            var mirrorSelector = SetupMultiMirrorSelector();
            var downloader     = SetupDefaultDownloader();
            var mDownloader    = new MultiMirrorFileDownloader(downloader, mirrorSelector);

            Action act = () => mDownloader.Download(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);
        }
示例#3
0
        public void SuccessDownloadShouldBeRegistered()
        {
            var mirrorSelector = SetupDefaultMirrorSelector();
            var downloader     = A.Fake <IFileDownloader>();
            var mDownloader    = new MultiMirrorFileDownloader(downloader, mirrorSelector);

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

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