コード例 #1
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();
            }
        }
コード例 #2
0
        public void Should_EnterSearchFailedState_When_AbortSearch()
        {
            var session = new UpdateSessionFake(true);

            session.SearcherMock.FakeSearchTimeMs = 10000;

            using (WuApiController wu = new WuApiController(session, UpdateCollectionFactory, SystemInfo))
            {
                wu.BeginSearchUpdates();
                Assert.AreEqual(WuStateId.SearchFailed, wu.AbortSearchUpdates());
                Assert.AreEqual(WuStateId.SearchFailed, wu.GetWuStatus().StateId);
            }
        }
        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_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));
            }
        }
        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"));
            }
        }