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_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_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_NotThrowExpection_When_CreateWuApiControllerWithDefaultConstructor() { using (WuApiController wu = new WuApiController()) { Assert.IsTrue(wu.GetAvailableUpdates().Count == 0); } }
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_MarkUpdateAsUnselected_When_UnselectUpdate() { UpdateSessionFake session = new UpdateSessionFake(true); var update1 = new UpdateFake("update1", true); session.SearcherMock.FakeSearchResult = CommonMocks.GetSearchResult(ToUpdateCollection(update1)); using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo)) { wu.AutoSelectUpdates = true; wu.BeginSearchUpdates(); WaitForStateChange(wu, WuStateId.SearchCompleted); Assert.IsTrue(wu.GetAvailableUpdates().Single().SelectedForInstallation); wu.UnselectUpdate("update1"); Assert.IsFalse(wu.GetAvailableUpdates().Single().SelectedForInstallation); } }
public void Should_ReturnDefaults_When_CreateWuApiController() { var session = new UpdateSessionFake(true); using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo)) { Assert.IsFalse(wu.AutoAcceptEulas); Assert.IsTrue(wu.AutoSelectUpdates); Assert.IsFalse(wu.GetAvailableUpdates().Any()); } }
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"); } }
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_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); } }