public void Should_AcceptEula_When_EulaIsNotAccepted()
        {
            UpdateSessionFake session = new UpdateSessionFake(true);

            var update1 = new UpdateFake("update1", true);
            var update2 = new UpdateFake("update2", true);

            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update1, update2));

            update1.EulaAccepted = false;
            update1.Identity     = CommonMocks.GetUpdateIdentity("update1Id");
            update2.EulaAccepted = false;
            update2.Identity     = CommonMocks.GetUpdateIdentity("update2Id");

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas = false;

                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);

                var updates = wu.GetAvailableUpdates();

                Assert.IsNotNull(updates.Single(u => u.ID.Equals("update1Id")));
                Assert.IsNotNull(updates.Single(u => u.ID.Equals("update2Id")));

                wu.AcceptEula(updates.Single(u => u.ID.Equals("update1Id")));
                Assert.IsTrue(wu.GetAvailableUpdates().Single(u => u.ID.Equals("update1Id")).EulaAccepted);
                wu.AcceptEula(updates.Single(u => u.ID.Equals("update2Id")).ID);
                Assert.IsTrue(wu.GetAvailableUpdates().Single(u => u.ID.Equals("update2Id")).EulaAccepted);
            }
        }
        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);
                }
            }
        }
        public void Should_AcceptEulas_When_BeginDownloadingAndAutoAcceptEnabled()
        {
            var session = new UpdateSessionFake(true);

            var update1 = new UpdateFake("update1", true);

            update1.EulaAccepted = false;
            var update2 = new UpdateFake("update2", true);

            update2.EulaAccepted = true;
            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update1, update2));

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas = true;
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.BeginDownloadUpdates();
                WaitForStateChange(wu, WuStateId.DownloadCompleted);
                Assert.IsTrue(update1.EulaAccepted);
                Assert.IsTrue(update2.EulaAccepted);
                Assert.AreEqual(wu.GetAvailableUpdates().Count, 2);
                Assert.IsTrue(wu.GetAvailableUpdates().All(u => u.IsDownloaded && u.EulaAccepted));
            }
        }
        public void Should_NotAcceptEula_When_UpdateIsNotSelected()
        {
            UpdateSessionFake session = new UpdateSessionFake(true);

            var update1 = new UpdateFake("update1", false);
            var update2 = new UpdateFake("update2", false);

            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update1, update2));
            update1.EulaAccepted = false;
            update2.EulaAccepted = false;

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas   = true;
                wu.AutoSelectUpdates = false;

                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.SelectUpdate(update2.Identity.UpdateID);
                wu.BeginDownloadUpdates();
                WaitForStateChange(wu, WuStateId.DownloadCompleted);

                var updates = wu.GetAvailableUpdates();

                Assert.IsFalse(updates.Single(u => u.ID.Equals("update1")).SelectedForInstallation);
                Assert.IsFalse(updates.Single(u => u.ID.Equals("update1")).EulaAccepted);
                Assert.IsTrue(updates.Single(u => u.ID.Equals("update2")).EulaAccepted);
                Assert.IsTrue(updates.Single(u => u.ID.Equals("update2")).SelectedForInstallation);
            }
        }
        public void Should_NotDownloadInstalledUpdates_When_DownloadUpdates()
        {
            var session = new UpdateSessionFake(true);

            var update1 = new UpdateFake("update1", true);

            update1.IsInstalled  = false;
            update1.IsDownloaded = false;
            var update2 = new UpdateFake("update2", true);

            update2.IsInstalled  = false;
            update2.IsDownloaded = false;
            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update1, update2));

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas = true;
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                update1.IsInstalled = true;
                wu.BeginDownloadUpdates();
                WaitForStateChange(wu, WuStateId.DownloadCompleted);
                Assert.AreEqual(wu.GetAvailableUpdates().Count, 2);
                Assert.IsNotNull(wu.GetAvailableUpdates().SingleOrDefault(u => u.ID.Equals("update1") && !u.IsDownloaded && u.IsInstalled));
                Assert.IsNotNull(wu.GetAvailableUpdates().SingleOrDefault(u => u.ID.Equals("update2") && u.IsDownloaded && !u.IsInstalled));
            }
        }
        public void Should_NotEnterDonwloadingState_When_NoUpdatesAvailable()
        {
            var session = new UpdateSessionFake(true);

            var update1 = new UpdateFake("update1", true);

            update1.IsInstalled  = true;
            update1.IsDownloaded = false;
            var update2 = new UpdateFake("update2", true);

            update2.IsDownloaded = true;


            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                try
                {
                    wu.BeginDownloadUpdates(); // nerver searched for updates, no updates should be available
                    Assert.Fail("exception expected");
                }
                catch (InvalidStateTransitionException) { }

                session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update1, update2));
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);

                try
                {
                    wu.BeginDownloadUpdates(); // available updates are already installed or downloaded
                    Assert.Fail("exception expected");
                }
                catch (InvalidStateTransitionException) { }
            }
        }
Exemple #7
0
        public void Should_NotEnterDownloadingState_When_InstallerRequiresReboot()
        {
            var session = new UpdateSessionFake(true);

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

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.BeginInstallUpdates();
            }
        }
        public void Should_ThrowException_When_SelectUnkownUpdate()
        {
            UpdateSessionFake session = new UpdateSessionFake(true);

            var update1 = new UpdateFake("update1", false);

            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update1));

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.SelectUpdate("update2");
            }
        }
Exemple #9
0
        public void Should_NotInstallAlreadyInstalledUpdates_When_BeginInstallUpdates()
        {
            var session = new UpdateSessionFake(true);
            var update1 = new UpdateFake("update1", true);

            update1.IsInstalled = true;
            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update1));

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.BeginInstallUpdates();
            }
        }
        public void Should_EnterDownloadCompletedState_When_DownloadCompleted()
        {
            var session = new UpdateSessionFake(true);

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

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas = true;
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.BeginDownloadUpdates();
                WaitForStateChange(wu, WuStateId.DownloadCompleted);
            }
        }
        public void Should_MarkUpdateAsSelected_When_SelectUpdate()
        {
            UpdateSessionFake session = new UpdateSessionFake(true);

            var update1 = new UpdateFake("update1", false);

            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update1));

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.SelectUpdate("update1");
                Assert.IsTrue(wu.GetAvailableUpdates().Single().SelectedForInstallation);
            }
        }
Exemple #12
0
        public void Should_UpdateSetProgressDescription_When_BeginSearch()
        {
            UpdateSessionFake session = new UpdateSessionFake(true);
            UpdateFake        update  = new UpdateFake("update1", true);

            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update));
            session.SearcherMock.FakeSearchTimeMs = 10000;

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.BeginSearchUpdates();
                Assert.IsNotNull(wu.GetWuStatus().Progress);
                Assert.IsNull(wu.GetWuStatus().Progress.Count);
                wu.AbortSearchUpdates();
            }
        }
        public void Should_EnterDownloadFailedState_When_AbortDownload()
        {
            var session = new UpdateSessionFake(true);

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

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas = true;
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.BeginDownloadUpdates();
                Assert.AreEqual(WuStateId.DownloadFailed, wu.AbortDownloadUpdates());
                Assert.AreEqual(WuStateId.DownloadFailed, wu.GetWuStatus().StateId);
            }
        }
        public void Should_ThrowException_When_AcceptEulaOfUnkownUpdate()
        {
            UpdateSessionFake session = new UpdateSessionFake(true);

            var update1 = new UpdateFake("update1", true);

            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update1));
            update1.EulaAccepted = true;
            update1.Identity     = CommonMocks.GetUpdateIdentity("update1Id");

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas = false;
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.AcceptEula("update2Id");
            }
        }
Exemple #15
0
        public void Should_SkipInstalledUpdates_When_SearchCompleted()
        {
            UpdateFake update = new UpdateFake("update1");

            update.IsInstalled = true;
            IUpdateCollection updateCollection = ToUpdateCollection(update);

            var session = new UpdateSessionFake(true);

            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(updateCollection);

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                Assert.IsTrue(wu.GetAvailableUpdates().Count == 0);
            }
        }
        public void Should_NotEnterDownloadingState_When_NotEnoughFreeSpaceAvailable()
        {
            var system    = MoqFactory.Create <ISystemInfo>(MockBehavior.Loose);
            int freespace = 100;

            system.Setup(s => s.GetFreeSpace()).Returns(freespace);
            system.Setup(s => s.GetFQDN()).Returns("fqdn");
            system.Setup(s => s.GetOperatingSystemName()).Returns("osname");
            system.Setup(s => s.GetWuServer()).Returns("update server");
            system.Setup(s => s.GetTargetGroup()).Returns("target group");

            UpdateFake update = new UpdateFake("update1");

            update.IsMandatory     = true;
            update.EulaAccepted    = true;
            update.MaxDownloadSize = freespace;
            UpdateFake update2 = new UpdateFake("update2");

            update2.IsMandatory              = true;
            update2.EulaAccepted             = true;
            update2.RecommendedHardDiskSpace = 10;

            IUpdateCollection updateCollection = ToUpdateCollection(update, update2);

            var session = new UpdateSessionFake(true);

            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(updateCollection);

            WuApiController wu = new WuApiController(session, UpdateCollectionFactory, system.Object);

            wu.BeginSearchUpdates();
            WaitForStateChange(wu, WuStateId.SearchCompleted);

            try
            {
                wu.BeginDownloadUpdates();
                Assert.Fail("exception expected");
            }
            catch (InvalidStateTransitionException e)
            {
                Assert.IsTrue(e.Message.Contains("free space"));
                Assert.IsTrue(wu.GetWuStatus().Equals(WuStateId.SearchCompleted));
            }
        }
Exemple #17
0
        public void Should_EnterRebootRequiredState_When_UpdateInstallationRequiresReboot()
        {
            var session = new UpdateSessionFake(true);
            var update  = new UpdateFake("update1", true);

            update.IsDownloaded = true;

            session.SearcherMock.FakeSearchResult   = CommonMocks.GetSearchResult(ToUpdateCollection(update));
            session.InstallerMock.FakeInstallResult = CommonMocks.GetInstallationResult(OperationResultCode.orcSucceeded, 0, true);

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas = true;
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.BeginInstallUpdates();
                WaitForStateChange(wu, WuStateId.RebootRequired);
            }
        }
        public void Should_EnterDownloadFailedState_When_DownloadTimeRunsOut()
        {
            UpdateFake        update           = new UpdateFake("update1", true);
            IUpdateCollection updateCollection = ToUpdateCollection(update);

            var session = new UpdateSessionFake(true);

            session.SearcherMock.FakeSearchResult     = CommonMocks.GetSearchResult(updateCollection);
            session.DownloaderMock.FakeDownloadTimeMs = 10000;

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas = true;
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.BeginDownloadUpdates(1);
                WaitForStateChange(wu, WuStateId.DownloadFailed, 2000);
                Assert.IsTrue(wu.GetWuStatus().Description.Contains("Timeout"));
            }
        }
        public void Should_ThrowException_When_TimeoutValueIsToHigh()
        {
            UpdateSessionFake session = new UpdateSessionFake(true);

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

            int max        = int.MaxValue / 1000;
            int outOfRange = max + 1;

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas = true;

                try
                {
                    wu.BeginSearchUpdates(outOfRange);
                    Assert.Fail("exception expected");
                }
                catch (ArgumentOutOfRangeException) { }
                wu.BeginSearchUpdates(max);
                WaitForStateChange(wu, WuStateId.SearchCompleted);

                try
                {
                    wu.BeginDownloadUpdates(outOfRange);
                    Assert.Fail("exception expected");
                }
                catch (ArgumentOutOfRangeException) { }
                wu.BeginDownloadUpdates(max);
                WaitForStateChange(wu, WuStateId.DownloadCompleted);

                try
                {
                    wu.BeginInstallUpdates(outOfRange);
                    Assert.Fail("exception expected");
                }
                catch (ArgumentOutOfRangeException) { }
                wu.BeginInstallUpdates(max);
                WaitForStateChange(wu, WuStateId.InstallCompleted);
            }
        }
Exemple #20
0
        public void Should_EnterUserInputRequiredState_When_NotInstalledUpdateCanRequestInput()
        {
            var session   = new UpdateSessionFake(true);
            var behavMock = new Mock <IInstallationBehavior>();

            behavMock.Setup(b => b.CanRequestUserInput).Returns(true);
            var update = new UpdateFake("update1", true);

            update.IsDownloaded                   = true;
            update.InstallationBehavior           = behavMock.Object;
            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update));

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas = true;
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                wu.BeginInstallUpdates();
                WaitForStateChange(wu, WuStateId.UserInputRequired);
            }
        }
Exemple #21
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);
        }
        public void Should_FireProgressChangedEvent_When_ProgressHasChanged()
        {
            var session = new UpdateSessionFake(true);

            var u1 = new UpdateFake("1", true);
            var u2 = new UpdateFake("2", true);

            List <Action> asserts = new List <Action>(); // assert in others threads will not be caught

            session.SearcherMock.FakeSearchResult     = CommonMocks.GetSearchResult(ToUpdateCollection(u1, u2));
            session.DownloaderMock.FakeDownloadTimeMs = 101;

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

                wu.OnProgressChanged += (sender, args) =>
                {
                    if (args.Progress.CurrentUpdate.ID == u1.Identity.UpdateID)
                    {
                        asserts.Add(() => { Assert.AreEqual(args.Progress.CurrentIndex, 0); });
                        asserts.Add(() => { Assert.AreEqual(args.Progress.Count, 2); });
                    }
                    else if (args.Progress.CurrentUpdate.ID == u2.Identity.UpdateID)
                    {
                        asserts.Add(() => { Assert.AreEqual(args.Progress.CurrentIndex, 1); });
                        asserts.Add(() => { Assert.AreEqual(args.Progress.Count, 2); });
                    }
                    else
                    {
                        asserts.Add(() => { Assert.Fail("unkown update"); });
                    }
                };
                WaitForStateChange(wu, WuStateId.DownloadCompleted);
                asserts.ForEach(a => a()); // fire asserts
            }
        }
Exemple #23
0
        public void Should_ConvertValues_When_ConvertUpdateToTransferObject()
        {
            Update3Fake update = new Update3Fake("update1", false);

            update.IsInstalled     = false;
            update.Identity        = CommonMocks.GetUpdateIdentity("update");
            update.Description     = "some text about me";
            update.IsDownloaded    = false;
            update.MaxDownloadSize = 5;
            update.MinDownloadSize = 1;
            update.Title           = "i am the update";
            update.EulaAccepted    = true;

            IUpdateCollection updateCollection = ToUpdateCollection(update);

            var session = new UpdateSessionFake(true);

            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(updateCollection);
            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoSelectUpdates = true;
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);

                UpdateDescription ud = wu.GetAvailableUpdates().Single();

                Assert.AreEqual(ud.IsImportant, !update.BrowseOnly);
                Assert.AreEqual(ud.Description, update.Description);
                Assert.AreEqual(ud.ID, update.Identity.UpdateID);
                Assert.AreEqual(ud.IsDownloaded, update.IsDownloaded);
                Assert.AreEqual(ud.IsInstalled, update.IsInstalled);
                Assert.AreEqual(ud.MaxByteSize, update.MaxDownloadSize);
                Assert.AreEqual(ud.MinByteSize, update.MinDownloadSize);
                Assert.AreEqual(ud.Title, update.Title);
                Assert.AreEqual(ud.EulaAccepted, update.EulaAccepted);
                Assert.AreEqual(ud.SelectedForInstallation, !update.BrowseOnly);
            }
        }
        public void Should_FireAsyncOperationCompletedEvent_When_AsyncOperationCompleted()
        {
            var session = new UpdateSessionFake(true);

            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(new UpdateFake("u", true)));
            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoAcceptEulas = true;

                ManualResetEvent eventSignal = new ManualResetEvent(false);
                AsyncOperation   result      = AsyncOperation.Installing;
                wu.OnAsyncOperationCompleted += (sender, args) => { result = args.Operation; eventSignal.Set(); };

                eventSignal.Reset();
                wu.BeginSearchUpdates();
                if (!eventSignal.WaitOne(1000))
                {
                    Assert.Fail("expected event not fired");
                }
                Assert.AreEqual(AsyncOperation.Searching, result);

                eventSignal.Reset();
                wu.BeginDownloadUpdates();
                if (!eventSignal.WaitOne(1000))
                {
                    Assert.Fail("expected event not fired");
                }
                Assert.AreEqual(AsyncOperation.Downloading, result);

                eventSignal.Reset();
                wu.BeginInstallUpdates();
                if (!eventSignal.WaitOne(1000))
                {
                    Assert.Fail("expected event not fired");
                }
                Assert.AreEqual(AsyncOperation.Installing, result);
            }
        }
Exemple #25
0
        public void Should_EnterSearchFailedState_When_SearchCompletedWithErrors()
        {
            var session = new UpdateSessionFake(true);

            session.SearcherMock.FakeSearchTimeMs = 1;

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

            results.Add(CommonMocks.GetSearchResult(ToUpdateCollection(new UpdateFake("update")), OperationResultCode.orcAborted));
            results.Add(CommonMocks.GetSearchResult(ToUpdateCollection(new UpdateFake("update")), OperationResultCode.orcFailed));
            results.Add(CommonMocks.GetSearchResult(ToUpdateCollection(new UpdateFake("update")), OperationResultCode.orcNotStarted));
            results.Add(CommonMocks.GetSearchResult(ToUpdateCollection(new UpdateFake("update")), OperationResultCode.orcSucceededWithErrors));

            foreach (var result in results)
            {
                session.SearcherMock.FakeSearchResult = result;
                using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
                {
                    wu.BeginSearchUpdates();
                    WaitForStateChange(wu, WuStateId.SearchFailed);
                }
            }
        }
Exemple #26
0
        public void Should_UpdateApplicableUpdateList_When_SearchCompleted()
        {
            UpdateSessionFake session = new UpdateSessionFake(true);

            UpdateFake update = new UpdateFake("update1");

            update.IsMandatory = true;
            UpdateFake update2 = new UpdateFake("update2");

            update2.IsMandatory = false;

            session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update, update2));

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.AutoSelectUpdates = true;
                wu.BeginSearchUpdates();
                WaitForStateChange(wu, WuStateId.SearchCompleted);
                Assert.IsTrue(wu.GetAvailableUpdates().Count == 2);
                Assert.IsTrue(wu.GetAvailableUpdates().First().ID == "update1");
                Assert.IsTrue(wu.GetAvailableUpdates().Skip(1).First().ID == "update2");
            }
        }