public void TestNotAlreadyInstalledReturnsFalse() { _mResolver.Setup(r => r.CheckInstalled()).Returns(false); UninstallCommand uninstallCommand = new UninstallCommand(_mResolver.Object, "", _mLogger.Object); Assert.False(uninstallCommand.Execute()); }
private void ModelOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) { if (propertyChangedEventArgs.PropertyName == "MarkedForUninstall") { UnmarkForUninstallationCommand.RaiseCanExecuteChanged(); UninstallCommand.RaiseCanExecuteChanged(); } }
public void TestResolveReturnsTrue() { _mResolver.Setup(r => r.CheckInstalled()).Returns(true); _mResolver.Setup(r => r.Remove()).Returns(true); UninstallCommand uninstallCommand = new UninstallCommand(_mResolver.Object, "", _mLogger.Object); Assert.True(uninstallCommand.Execute()); }
private void RefreshCommands() { InstallCommand.RaiseCanExecuteChanged(); UninstallCommand.RaiseCanExecuteChanged(); StartCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); RaisePropertyChanged("ServiceStatus"); RaisePropertyChanged("IsWorking"); }
// Calls RaisePropertyChanged for all PackageLoadState related properties internal void NotifyLoadStatePropertyChanged() { UninstallCommand.RaiseCanExecuteChanged(); UnmarkForUninstallationCommand.RaiseCanExecuteChanged(); LoadCommand.RaiseCanExecuteChanged(); RaisePropertyChanged(nameof(PackageLoadStateTooltip)); RaisePropertyChanged(nameof(PackageLoadStateText)); RaisePropertyChanged(nameof(Unloaded)); }
public InstalledViewModel(IPackageSourceSelector packageSource, IInstallService service, SelfPackageConfiguration selfPackageConfiguration) { Ensure.NotNull(service, "service"); this.service = service; Packages = new ObservableCollection <IInstalledPackage>(); Refresh = new RefreshInstalledCommand(this, packageSource, service); Reinstall = new ReinstallCommand(service, selfPackageConfiguration); Uninstall = new UninstallCommand(service, selfPackageConfiguration); UninstallAll = new UninstallAllCommand(this); }
public void TestUninstall_NoLibraryToUninstall() { var command = new UninstallCommand(HostEnvironment); command.Configure(null); string contents = @"{ ""version"": ""1.0"", ""defaultProvider"": ""cdnjs"", ""defaultDestination"": ""wwwroot"", ""libraries"": [ { ""provider"": ""cdnjs"", ""library"": ""[email protected]"", ""destination"": ""wwwroot"", ""files"": [ ""jquery.min.js"", ""core.js"" ] } ] }"; string libmanjsonPath = Path.Combine(WorkingDir, "libman.json"); File.WriteAllText(libmanjsonPath, contents); var restoreCommand = new RestoreCommand(HostEnvironment); restoreCommand.Configure(null); restoreCommand.Execute(); Assert.IsTrue(File.Exists(Path.Combine(WorkingDir, "wwwroot", "jquery.min.js"))); Assert.IsTrue(File.Exists(Path.Combine(WorkingDir, "wwwroot", "core.js"))); int result = command.Execute("[email protected]"); Assert.AreEqual(0, result); Assert.IsTrue(File.Exists(Path.Combine(WorkingDir, "wwwroot", "jquery.min.js"))); Assert.IsTrue(File.Exists(Path.Combine(WorkingDir, "wwwroot", "core.js"))); var logger = HostEnvironment.Logger as TestLogger; Assert.AreEqual("Library \"[email protected]\" is not installed. Nothing to uninstall", logger.Messages[logger.Messages.Count - 1].Value); string actualText = File.ReadAllText(libmanjsonPath); Assert.AreEqual(StringHelper.NormalizeNewLines(contents), StringHelper.NormalizeNewLines(actualText)); }
public void TestUninstall() { var command = new UninstallCommand(HostEnvironment); command.Configure(null); string contents = @"{ ""version"": ""1.0"", ""defaultProvider"": ""cdnjs"", ""defaultDestination"": ""wwwroot"", ""libraries"": [ { ""library"": ""[email protected]"", ""files"": [ ""jquery.min.js"", ""core.js"" ] } ] }"; string libmanjsonPath = Path.Combine(WorkingDir, "libman.json"); File.WriteAllText(libmanjsonPath, contents); var restoreCommand = new RestoreCommand(HostEnvironment); restoreCommand.Configure(null); restoreCommand.Execute(); Assert.IsTrue(File.Exists(Path.Combine(WorkingDir, "wwwroot", "jquery.min.js"))); Assert.IsTrue(File.Exists(Path.Combine(WorkingDir, "wwwroot", "core.js"))); int result = command.Execute("[email protected]"); Assert.AreEqual(0, result); Assert.IsFalse(File.Exists(Path.Combine(WorkingDir, "wwwroot", "jquery.min.js"))); Assert.IsFalse(File.Exists(Path.Combine(WorkingDir, "wwwroot", "core.js"))); string expectedText = @"{ ""version"": ""1.0"", ""defaultProvider"": ""cdnjs"", ""defaultDestination"": ""wwwroot"", ""libraries"": [] }"; string actualText = File.ReadAllText(libmanjsonPath); Assert.AreEqual(StringHelper.NormalizeNewLines(expectedText), StringHelper.NormalizeNewLines(actualText)); }
public PackageManagerDialogViewModel() : base("Packages") { _packageManager = new PackageManager(this); AvailablePackages = new ObservableCollection <IPackageSearchMetadata>(); Dispatcher.UIThread.InvokeAsync(async() => { InvalidateInstalledPackages(); await DownloadCatalog(); }); InstallCommand = ReactiveCommand.Create(); InstallCommand.Subscribe(async _ => { await PackageManager.InstallPackage(selectedPackage.Identity.Id, selectedPackage.Identity.Version.ToFullString()); InvalidateInstalledPackages(); }); UninstallCommand = ReactiveCommand.Create(); UninstallCommand.Subscribe(async _ => { if (SelectedInstalledPackage != null) { await PackageManager.UninstallPackage(SelectedInstalledPackage.Model.Id, SelectedInstalledPackage.Model.Version.ToNormalizedString()); InvalidateInstalledPackages(); } }); OKCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.EnableInterface)); OKCommand.Subscribe(_ => { ShellViewModel.Instance.InvalidateCodeAnalysis(); Close(); }); EnableInterface = true; }
private void DetectInstalledPackage() { if (Configurator.IsApplicationInstalled(Settings.ApplicationName)) { UninstallEnabled = true; view.Dispatcher.Invoke(() => { UninstallCommand?.RaiseCanExecuteChanged(); }); } else { InstallEnabled = true; view.Dispatcher.Invoke(() => { InstallCommand?.RaiseCanExecuteChanged(); }); } }
public override bool OnContextItemSelected(IMenuItem item) { var info = (Android.Widget.AdapterView.AdapterContextMenuInfo)item.MenuInfo; var client = ((ClientListItem_Adapter)ListAdapter).GetClientFromPosition(info.Position); StaticCommand staticCommand = null; switch (item.ItemId) { case 0: ConnectionManager.Current.LogIn(client.Id); break; case 1: staticCommand = new MakeAdminCommand(); break; case 2: staticCommand = new UninstallCommand(); break; case 3: staticCommand = new KillCommand(); break; } if (staticCommand != null) { ConnectionManager.Current.StaticCommander.ExecuteCommand(staticCommand, new ImmediatelyTransmissionEvent(), null, null, CommandTarget.FromClients(new OnlineClientInformation { Id = client.Id })); } return(true); }
private void WorkspaceRemoved(WorkspaceModel ws) { UninstallCommand.RaiseCanExecuteChanged(); ws.NodeAdded -= NodeAddedOrRemovedHandler; ws.NodeRemoved -= NodeAddedOrRemovedHandler; }
private void NodeAddedOrRemovedHandler(object _) { UninstallCommand.RaiseCanExecuteChanged(); }
static int Main(string[] args) { Logger logger = new Logger(); var app = new CommandLineApplication(); app.Name = "dotnet get"; app.FullName = ".NET Core Tools Global Installer"; app.Description = "Install and use command line tools built on .NET Core"; app.HelpOption("-h|--help"); app.VersionOption("-v|--version", GetAssemblyVersion()); CommandOption verboseOption = app.Option("--verbose", "Enable verbose output", CommandOptionType.NoValue); app.OnExecute(() => { app.ShowHelp(); return(0); }); app.Command("install", c => { c.Description = "Installs a .NET Core tool"; c.HelpOption("-h|--help"); CommandArgument source = c.Argument("<SOURCE>", "The tool to install. Can be a NuGet package"); c.OnExecute(() => { logger = new Logger(verboseOption.HasValue()); if (string.IsNullOrWhiteSpace(source.Value)) { logger.LogError("<SOURCE> argument is required. Use -h|--help to see help"); return(1); } InstallCommand installCommand = new InstallCommand(source.Value, logger); return(installCommand.Execute() ? 0 : 1); }); }); app.Command("update", c => { c.Description = "Updates a .NET Core tool"; c.HelpOption("-h|--help"); CommandArgument source = c.Argument("<SOURCE>", "The tool to update."); c.OnExecute(() => { logger = new Logger(verboseOption.HasValue()); if (string.IsNullOrWhiteSpace(source.Value)) { return(Update(logger) ? 0 : 1); } UpdateCommand updateCommand = new UpdateCommand(source.Value, logger); return(updateCommand.Execute() ? 0 : 1); }); }); app.Command("list", c => { c.Description = "Lists all installed .NET Core tools"; c.HelpOption("-h|--help"); c.OnExecute(() => { logger = new Logger(verboseOption.HasValue()); ListCommand listCommand = new ListCommand(logger); return(listCommand.Execute() ? 0 : 1); }); }); app.Command("uninstall", c => { c.Description = "Uninstalls a .NET Core tool"; c.HelpOption("-h|--help"); CommandArgument source = c.Argument("<SOURCE>", "The tool to uninstall."); c.OnExecute(() => { logger = new Logger(verboseOption.HasValue()); if (string.IsNullOrWhiteSpace(source.Value)) { logger.LogError("<SOURCE> argument is required. Use -h|--help to see help"); return(1); } UninstallCommand uninstallCommand = new UninstallCommand(source.Value, logger); return(uninstallCommand.Execute() ? 0 : 1); }); }); try { return(app.Execute(args)); } catch (CommandParsingException ex) { logger.LogWarning(ex.Message); app.ShowHelp(); return(1); } }
public void TestNoResolverReturnsFalse() { UninstallCommand uninstallCommand = new UninstallCommand("/", _mLogger.Object); Assert.False(uninstallCommand.Execute()); }