Beispiel #1
0
        public void Should_SetCorrectStateId_When_CreateWuProcessStateObject()
        {
            var searching   = new WuStateSearching(new UpdateSearcherFake(), (x) => { }, (x, y) => { }, 100);
            var downloading = new WuStateDownloading(new UpdateDownloaderFake(), new UpdateCollectionFake(), (x, u) => { }, (x, y) => { }, null, 100);
            var installing  = new WuStateInstalling(new UpdateInstallerFake(), new UpdateCollectionFake(), (x, u) => { }, (x, y) => { }, null, 100);

            Assert.AreEqual(WuStateId.Searching, searching.StateId);
            Assert.AreEqual(WuStateId.Downloading, downloading.StateId);
            Assert.AreEqual(WuStateId.Installing, installing.StateId);

            searching.Dispose();
            downloading.Dispose();
            installing.Dispose();

            var sfailed  = new WuStateSearchFailed(null);
            var dfailed  = new WuStateDownloadFailed(null);
            var dpfailed = new WuStateDownloadPartiallyFailed(null);
            var ifailed  = new WuStateInstallFailed(null);
            var ipfailed = new WuStateInstallPartiallyFailed(null);

            Assert.AreEqual(WuStateId.SearchFailed, sfailed.StateId);
            Assert.AreEqual(WuStateId.DownloadFailed, dfailed.StateId);
            Assert.AreEqual(WuStateId.DownloadPartiallyFailed, dpfailed.StateId);
            Assert.AreEqual(WuStateId.InstallFailed, ifailed.StateId);
            Assert.AreEqual(WuStateId.InstallPartiallyFailed, ipfailed.StateId);

            var scom = new WuStateSearchCompleted(new UpdateCollectionFake());
            var dcom = new WuStateDownloadCompleted(new UpdateCollectionFake(), 0);
            var icom = new WuStateInstallCompleted(new UpdateCollectionFake(), 0);

            Assert.AreEqual(WuStateId.SearchCompleted, scom.StateId);
            Assert.AreEqual(WuStateId.DownloadCompleted, dcom.StateId);
            Assert.AreEqual(WuStateId.InstallCompleted, icom.StateId);

            var ready     = new WuStateReady();
            var rebootreq = new WuStateRebootRequired();
            var reboot    = new WuStateRestartSentToOS();
            var userinput = new WuStateUserInputRequired(String.Empty);


            Assert.AreEqual(WuStateId.Ready, ready.StateId);
            Assert.AreEqual(WuStateId.RebootRequired, rebootreq.StateId);
            Assert.AreEqual(WuStateId.RestartSentToOS, reboot.StateId);
            Assert.AreEqual(WuStateId.UserInputRequired, userinput.StateId);
        }
Beispiel #2
0
        public void Should_CallCompletedCallback_When_SearchingCompletes()
        {
            ManualResetEvent callbackSignal = new ManualResetEvent(false);
            ISearchResult    result         = null;

            WuStateSearching.SearchCompletedCallback callback = (x) => { result = x; callbackSignal.Set(); };
            IUpdateCollection updates = new UpdateCollectionFake();

            UpdateSearcherFake searcher = new UpdateSearcherFake();

            searcher.FakeSearchResult = CommonMocks.GetSearchResult(updates);

            var state = new WuStateSearching(searcher, callback, (x, y) => { }, 100);

            state.EnterState(new WuStateReady());
            if (!callbackSignal.WaitOne(1000))
            {
                Assert.Fail($"callback was not called");
            }
            Assert.AreSame(searcher.FakeSearchResult, result);
        }