Example #1
0
        public void Should_ContainSpecifiedValues_When_CreatePreConNotFullfilledException()
        {
            WuProcessState From = new WuStateReady(), To = new WuStateRebootRequired();
            Type           FromType = typeof(WuStateReady), ToType = typeof(WuStateRebootRequired);

            List <PreConditionNotFulfilledException> exceptions = new List <PreConditionNotFulfilledException>();

            exceptions.Add(new PreConditionNotFulfilledException(From, To, "message"));
            exceptions.Add(new PreConditionNotFulfilledException(From, To, "message", null));

            foreach (var ex in exceptions)
            {
                Assert.AreSame(From, ex.From);
                Assert.AreSame(To, ex.To);
            }

            exceptions.Clear();
            exceptions.Add(new PreConditionNotFulfilledException(FromType, ToType, "message"));
            exceptions.Add(new PreConditionNotFulfilledException(FromType, ToType, "message", null));

            foreach (var ex in exceptions)
            {
                Assert.AreSame(FromType, ex.FromType);
                Assert.AreSame(ToType, ex.ToType);
            }
        }
Example #2
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);
        }