Skip to content

Commit

Permalink
Multi-selection of packages for updating / uninstalling (#510)
Browse files Browse the repository at this point in the history
* Added option to select packages for updating

* Added option to select packages for uninstalling and option to uninstall all

* introduced some minor QoL changes: "Refresh" and "Preferences" buttons are now consistent, being drawn in the upper left on every tab; Search bar now doesn't have the "Search" button in "Installed" and "Updates" tabs - instead, every key stroke refreshes the filtered packages (it's a start for mentioned UX changes needed to improve the "Online" tab).

* Fixed unit tests

* Make search case-insensitive

* use function dienstend of Lambda

---------

Co-authored-by: JoC0de <53140583+JoC0de@users.noreply.github.com>
  • Loading branch information
popara96 and JoC0de authored May 3, 2023
1 parent 1360823 commit 8a12c82
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 95 deletions.
18 changes: 9 additions & 9 deletions src/NuGetForUnity.Tests/Assets/Tests/Editor/NuGetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class NuGetTests
[TearDown]
public void Cleanup()
{
NugetHelper.UninstallAll();
NugetHelper.UninstallAll(NugetHelper.InstalledPackages.ToList());
}

[Test]
Expand Down Expand Up @@ -44,7 +44,7 @@ public void InstallJsonTest()
NugetHelper.InstallIdentifier(json608);
Assert.IsTrue(NugetHelper.IsInstalled(json701), "The package was NOT installed: {0} {1}", json701.Id, json701.Version);

NugetHelper.UninstallAll();
NugetHelper.UninstallAll(NugetHelper.InstalledPackages.ToList());
Assert.IsFalse(NugetHelper.IsInstalled(json608), "The package is STILL installed: {0} {1}", json608.Id, json608.Version);
Assert.IsFalse(NugetHelper.IsInstalled(json701), "The package is STILL installed: {0} {1}", json701.Id, json701.Version);
}
Expand Down Expand Up @@ -87,7 +87,7 @@ public void InstallRoslynAnalyzerTest()
finally
{
// uninstall the package
NugetHelper.UninstallAll();
NugetHelper.UninstallAll(NugetHelper.InstalledPackages.ToList());
Assert.IsFalse(NugetHelper.IsInstalled(analyzer), "The package is STILL installed: {0} {1}", analyzer.Id, analyzer.Version);
}
}
Expand All @@ -102,7 +102,7 @@ public void InstallProtobufTest()
Assert.IsTrue(NugetHelper.IsInstalled(protobuf), "The package was NOT installed: {0} {1}", protobuf.Id, protobuf.Version);

// uninstall the package
NugetHelper.UninstallAll();
NugetHelper.UninstallAll(NugetHelper.InstalledPackages.ToList());
Assert.IsFalse(NugetHelper.IsInstalled(protobuf), "The package is STILL installed: {0} {1}", protobuf.Id, protobuf.Version);
}

Expand Down Expand Up @@ -140,7 +140,7 @@ public void InstallBootstrapCSSTest()
Assert.IsTrue(NugetHelper.IsInstalled(jQuery311), "The package was NOT installed: {0} {1}", jQuery311.Id, jQuery311.Version);

// cleanup and uninstall everything
NugetHelper.UninstallAll();
NugetHelper.UninstallAll(NugetHelper.InstalledPackages.ToList());

// confirm they are uninstalled
Assert.IsFalse(NugetHelper.IsInstalled(bootstrap337), "The package is STILL installed: {0} {1}", bootstrap337.Id, bootstrap337.Version);
Expand All @@ -165,7 +165,7 @@ public void InstallStyleCopTest()
Assert.IsTrue(NugetHelper.IsInstalled(styleCopId), "The package was NOT installed: {0} {1}", styleCopId.Id, styleCopId.Version);

// cleanup and uninstall everything
NugetHelper.UninstallAll();
NugetHelper.UninstallAll(NugetHelper.InstalledPackages.ToList());

Assert.IsFalse(NugetHelper.IsInstalled(styleCopPlusId), "The package is STILL installed: {0} {1}", styleCopPlusId.Id, styleCopPlusId.Version);
Assert.IsFalse(NugetHelper.IsInstalled(styleCopId), "The package is STILL installed: {0} {1}", styleCopId.Id, styleCopId.Version);
Expand Down Expand Up @@ -194,7 +194,7 @@ public void InstallSignalRClientTest()
}

// cleanup and uninstall everything
NugetHelper.UninstallAll();
NugetHelper.UninstallAll(NugetHelper.InstalledPackages.ToList());
Assert.IsFalse(NugetHelper.IsInstalled(signalRClient), "The package is STILL installed: {0} {1}", signalRClient.Id, signalRClient.Version);
}

Expand All @@ -220,7 +220,7 @@ public void InstallMicrosoftMlProbabilisticCompilerTest()
Assert.That(Path.Combine(libraryDirectory, "cs"), Does.Not.Exist);

// cleanup and uninstall everything
NugetHelper.UninstallAll();
NugetHelper.UninstallAll(NugetHelper.InstalledPackages.ToList());
Assert.IsFalse(
NugetHelper.IsInstalled(probabilisticCompiler),
"The package is STILL installed: {0} {1}",
Expand Down Expand Up @@ -442,7 +442,7 @@ public void TestUpgrading()
componentModelAnnotation47.Id,
componentModelAnnotation47.Version);

NugetHelper.UninstallAll();
NugetHelper.UninstallAll(NugetHelper.InstalledPackages.ToList());

Assert.IsFalse(
NugetHelper.IsInstalled(componentModelAnnotation5),
Expand Down
4 changes: 2 additions & 2 deletions src/NuGetForUnity/Editor/NugetHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,9 @@ private static void DeleteAllFiles(string directoryPath, string extension)
/// <summary>
/// Uninstalls all of the currently installed packages.
/// </summary>
internal static void UninstallAll()
internal static void UninstallAll(List<NugetPackage> packagesToUninstall)
{
foreach (var package in InstalledPackages.ToList())
foreach (var package in packagesToUninstall)
{
Uninstall(package);
}
Expand Down
Loading

0 comments on commit 8a12c82

Please sign in to comment.