protected override void EnterStateInternal(WuProcessState oldState)
        {
            lock (JobLock)
            {
                if (_uInstaller.IsBusy)
                {
                    throw new InvalidOperationException("Update installer is busy.");
                }
                if (_uInstaller.RebootRequiredBeforeInstallation)
                {
                    throw new InvalidOperationException("A reboot is required before update installation can start.");
                }

                _uInstaller.Updates = (UpdateCollection)_updates;
                var callbackReceiver = new CallbackReceiver(this);
                Job       = new WuApiInstallJobAdapter(_uInstaller.BeginInstall(callbackReceiver, callbackReceiver, null));
                StateDesc = $"Starting installation of {_updates.Count} update(s)";
            }
        }
Ejemplo n.º 2
0
        public void Should_PassThroughInvokes_When_UsingInstallAdapter()
        {
            var job     = MoqFactory.Create <IInstallationJob>(MockBehavior.Loose);
            var adapter = new WuApiInstallJobAdapter(job.Object);

            var x = adapter.AsyncState;

            job.Verify(j => j.AsyncState, Times.Once);

            var y = adapter.IsCompleted;

            job.Verify(j => j.IsCompleted, Times.Once);

            adapter.CleanUp();
            job.Verify(j => j.CleanUp(), Times.Once);

            adapter.RequestAbort();
            job.Verify(j => j.RequestAbort(), Times.Once);

            Assert.AreSame(job.Object, adapter.InternalJobObject);
        }