Пример #1
0
        public virtual void PrepareUnregisteringPrig(PrigPackageViewModel vm)
        {
            vm.BeginMachineWideProcessProgress(MachineWideProcesses.Uninstalling);

            var machinePreq = new MachinePrerequisite(Resources.NuGetRootPackageVersion);
            machinePreq.ProfilerStatusChecking += profLoc => vm.ReportProfilerStatusCheckingProgress(50u, profLoc);

            if (!MachineWideInstaller.HasBeenInstalled(machinePreq))
            {
                vm.ShowSkippedMachineWideProcessMessage(SkippedReasons.AlreadyRegistered);
                vm.EndSkippedMachineWideProcessProgress(SkippedReasons.AlreadyRegistered);
                return;
            }


            if (!WindowsIdentity.GetCurrent().IsElevated())
            {
                vm.ShowVisualStudioHasNotBeenElevatedYetMessage();
                if (ProcessMixin.RestartCurrentProcessWith(_ => { _.Verb = "runas"; }))
                    return;

                vm.EndSkippedMachineWideProcessProgress(SkippedReasons.CanceledByUser);
            }
            else
            {
                UnregisterPrig(vm);
            }
        }
Пример #2
0
        public void ShowVisualStudioHasNotBeenElevatedYetMessage_should_show_the_message_to_message_box()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var vm = new PrigPackageViewModel();

            // Act
            vm.ShowVisualStudioHasNotBeenElevatedYetMessage();


            // Assert
            var msgBox = vm.MessageBoxParameter.Value;
            Assert.AreEqual(OLEMSGBUTTON.OLEMSGBUTTON_OK, msgBox.Button);
            Assert.AreEqual(OLEMSGICON.OLEMSGICON_INFO, msgBox.Icon);
            Assert.IsNotNullOrEmpty(msgBox.Text);
        }