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_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");
            }
        }
Пример #3
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);
            }
        }