public void Should_EnterDownloadFailedState_When_DownloadFailed()
        {
            var session = new UpdateSessionFake(true);

            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(new UpdateFake("update1", true)));

            List <IDownloadResult> results = new List <IDownloadResult>();

            results.Add(CommonMocks.GetDownloadResult(OperationResultCode.orcFailed));
            results.Add(CommonMocks.GetDownloadResult(OperationResultCode.orcAborted));
            results.Add(CommonMocks.GetDownloadResult(OperationResultCode.orcNotStarted));

            foreach (var result in results)
            {
                session.DownloaderMock.FakeDownloadResult = result;
                using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
                {
                    wu.AutoAcceptEulas = true;
                    wu.BeginSearchUpdates();
                    WaitForStateChange(wu, WuStateId.SearchCompleted);
                    wu.BeginDownloadUpdates();
                    WaitForStateChange(wu, WuStateId.DownloadFailed);
                }
            }
        }
        private UpdateDownloaderFake GetDownloaderWithResultCode(OperationResultCode code)
        {
            UpdateDownloaderFake downloader = new UpdateDownloaderFake();

            downloader.FakeDownloadResult = CommonMocks.GetDownloadResult(code);
            return(downloader);
        }
        public void Should_EnterDownloadPartiallyFailedState_When_DownloadPartiallyFailed()
        {
            var session = new UpdateSessionFake(true);

            session.SearcherMock.FakeSearchResult     = CommonMocks.GetSearchResult(ToUpdateCollection(new UpdateFake("update1", true)));
            session.DownloaderMock.FakeDownloadResult = CommonMocks.GetDownloadResult(OperationResultCode.orcSucceededWithErrors);

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas = true;
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.BeginDownloadUpdates();
                WaitForStateChange(wu, WuStateId.DownloadPartiallyFailed);
            }
        }