From ccb5b6ea348d27cb213f9284fadce0b81f659be3 Mon Sep 17 00:00:00 2001 From: Cici Li Date: Thu, 14 Nov 2024 09:43:21 +0000 Subject: [PATCH 1/7] Add transitive package test cases --- .../NuGet.Tests.Apex.Daily/NuGetUITestCase.cs | 100 ++++++++++++++++++ .../Apex/NuGetUIProjectTestExtension.cs | 6 ++ 2 files changed, 106 insertions(+) diff --git a/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs b/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs index 26f4a63deb9..9ed1ce61848 100644 --- a/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs +++ b/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs @@ -497,6 +497,106 @@ public async Task Uninstall_WithMultiplePackagesThatDependOnEachOther_PackageGoe uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.Transitive); } + [TestMethod] + [Timeout(DefaultTimeout)] + public async Task SearchTopLevelPackageInInstalledTabFromUI_WhenThePackageHasTransitivePackage() + { + // Arrange + var transitivePackageName = "Contoso.B"; + await CommonUtility.CreateDependenciesPackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1, transitivePackageName, TestPackageVersionV1); + + NuGetApexTestService nugetTestService = GetNuGetTestService(); + + var solutionService = VisualStudio.Get(); + solutionService.CreateEmptySolution("TestSolution", _pathContext.SolutionRoot); + var project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.NetCoreClassLib, "TestProject"); + VisualStudio.ClearOutputWindow(); + solutionService.SaveAll(); + + CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); + + var uiwindow = nugetTestService.GetUIWindowfromProject(project); + uiwindow.InstallPackageFromUI(TestPackageName, TestPackageVersionV1); + solutionService.Build(); + + CommonUtility.AssertPackageReferenceExists(VisualStudio, project, TestPackageName, TestPackageVersionV1, Logger); + uiwindow.AssertPackageNameAndType(TestPackageName, NuGet.VisualStudio.PackageLevel.TopLevel); + uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.Transitive); + + // Act + uiwindow.SearchPackageFromUI(TestPackageName); + + // Assert + VisualStudio.AssertNoErrors(); + uiwindow.AssertPackageNameAndType(TestPackageName, NuGet.VisualStudio.PackageLevel.TopLevel); + } + + [TestMethod] + [Timeout(DefaultTimeout)] + public async Task InstallTopLevelPackage_WhenHasTransitivePackageFromUI() + { + // Arrange + var transitivePackageName = "Contoso.B"; + await CommonUtility.CreateDependenciesPackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1, transitivePackageName, TestPackageVersionV1); + + NuGetApexTestService nugetTestService = GetNuGetTestService(); + + var solutionService = VisualStudio.Get(); + solutionService.CreateEmptySolution("TestSolution", _pathContext.SolutionRoot); + var project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.NetCoreConsoleApp, "TestProject"); + VisualStudio.ClearOutputWindow(); + solutionService.SaveAll(); + + CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); + + // Act + var uiwindow = nugetTestService.GetUIWindowfromProject(project); + uiwindow.InstallPackageFromUI(TestPackageName, TestPackageVersionV1); + solutionService.Build(); + + // Assert + VisualStudio.AssertNoErrors(); + uiwindow.AssertPackageNameAndType(TestPackageName, NuGet.VisualStudio.PackageLevel.TopLevel); + uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.Transitive); + CommonUtility.AssertPackageReferenceExists(VisualStudio, project, TestPackageName, TestPackageVersionV1, Logger); + } + + [TestMethod] + [Timeout(DefaultTimeout)] + public async Task UninstallTopLevelPackage_WhenHasTransitivePackage() + { + // Arrange + var transitivePackageName = "Contoso.B"; + await CommonUtility.CreateDependenciesPackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1, transitivePackageName, TestPackageVersionV1); + + NuGetApexTestService nugetTestService = GetNuGetTestService(); + + var solutionService = VisualStudio.Get(); + solutionService.CreateEmptySolution("TestSolution", _pathContext.SolutionRoot); + var project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.NetCoreClassLib, "Testproject"); + VisualStudio.ClearOutputWindow(); + solutionService.SaveAll(); + + CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); + + var uiwindow = nugetTestService.GetUIWindowfromProject(project); + uiwindow.InstallPackageFromUI(TestPackageName, TestPackageVersionV1); + solutionService.Build(); + + CommonUtility.AssertPackageReferenceExists(VisualStudio, project, TestPackageName, TestPackageVersionV1, Logger); + uiwindow.AssertPackageNameAndType(TestPackageName, NuGet.VisualStudio.PackageLevel.TopLevel); + uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.Transitive); + + // Act + uiwindow.UninstallPackageFromUI(TestPackageName); + solutionService.Build(); + + // Assert + VisualStudio.AssertNoErrors(); + uiwindow.AssertPackageListIsNullIninsatlltab(); + CommonUtility.AssertPackageReferenceDoesNotExist(VisualStudio, project, TestPackageName, Logger); + } + [TestMethod] [DataRow(ProjectTemplate.NetCoreConsoleApp)] [DataRow(ProjectTemplate.ConsoleApplication)] diff --git a/test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs b/test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs index 7225238558d..9958300e171 100644 --- a/test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs +++ b/test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.Linq; using FluentAssertions; +using Microsoft.TeamFoundation.Common; using Microsoft.Test.Apex.Services; using NuGet.PackageManagement.UI; using NuGet.PackageManagement.UI.TestContract; @@ -76,6 +77,11 @@ public void AssertPackageNameAndType(string packageId, PackageLevel packageLevel package.Id.Should().Be(packageId); } + public bool AssertPackageListIsNullIninsatlltab() + { + return _uiproject.PackageItems.IsNullOrEmpty(); + } + public bool InstallPackageFromUI(string packageId, string version) { Stopwatch sw = Stopwatch.StartNew(); From 765867bf101b2d3b1ff9d90e46c7e9420edb4389 Mon Sep 17 00:00:00 2001 From: Cici Li Date: Fri, 15 Nov 2024 09:09:49 +0000 Subject: [PATCH 2/7] update test name --- .../NuGet.Tests.Apex.Daily/NuGetUITestCase.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs b/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs index 9ed1ce61848..7df45a065c7 100644 --- a/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs +++ b/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs @@ -499,7 +499,7 @@ public async Task Uninstall_WithMultiplePackagesThatDependOnEachOther_PackageGoe [TestMethod] [Timeout(DefaultTimeout)] - public async Task SearchTopLevelPackageInInstalledTabFromUI_WhenThePackageHasTransitivePackage() + public async Task SearchTopLevelPackageInInstalledTabFromUI() { // Arrange var transitivePackageName = "Contoso.B"; @@ -533,7 +533,7 @@ public async Task SearchTopLevelPackageInInstalledTabFromUI_WhenThePackageHasTra [TestMethod] [Timeout(DefaultTimeout)] - public async Task InstallTopLevelPackage_WhenHasTransitivePackageFromUI() + public async Task InstallTopLevelPackage() { // Arrange var transitivePackageName = "Contoso.B"; @@ -563,7 +563,7 @@ public async Task InstallTopLevelPackage_WhenHasTransitivePackageFromUI() [TestMethod] [Timeout(DefaultTimeout)] - public async Task UninstallTopLevelPackage_WhenHasTransitivePackage() + public async Task UninstallTopLevelPackage() { // Arrange var transitivePackageName = "Contoso.B"; From e0fea3b4750c98b719a4070c9607a9fa3b47830a Mon Sep 17 00:00:00 2001 From: Cici Li Date: Fri, 15 Nov 2024 09:13:47 +0000 Subject: [PATCH 3/7] update test name --- .../NuGet.Tests.Apex.Daily/NuGetUITestCase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs b/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs index 7df45a065c7..e536317333a 100644 --- a/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs +++ b/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs @@ -533,7 +533,7 @@ public async Task SearchTopLevelPackageInInstalledTabFromUI() [TestMethod] [Timeout(DefaultTimeout)] - public async Task InstallTopLevelPackage() + public async Task InstallTopLevelPackageFromUI() { // Arrange var transitivePackageName = "Contoso.B"; @@ -563,7 +563,7 @@ public async Task InstallTopLevelPackage() [TestMethod] [Timeout(DefaultTimeout)] - public async Task UninstallTopLevelPackage() + public async Task UninstallTopLevelPackageFromUI() { // Arrange var transitivePackageName = "Contoso.B"; From c888b5066ae435683582d7dc07092c14ee8b254b Mon Sep 17 00:00:00 2001 From: CiciLi1 <84695155+CiciLi1@users.noreply.github.com> Date: Fri, 22 Nov 2024 09:17:00 +0800 Subject: [PATCH 4/7] Update method name Co-authored-by: Jeff Kluge --- .../NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs b/test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs index 9958300e171..96410b6ad1c 100644 --- a/test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs +++ b/test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs @@ -77,7 +77,7 @@ public void AssertPackageNameAndType(string packageId, PackageLevel packageLevel package.Id.Should().Be(packageId); } - public bool AssertPackageListIsNullIninsatlltab() + public bool AssertPackageListIsNullOrEmpty() { return _uiproject.PackageItems.IsNullOrEmpty(); } From 4df02685727851b73e4e87bbe0c153cd0d740df3 Mon Sep 17 00:00:00 2001 From: Cici Li Date: Fri, 22 Nov 2024 02:59:51 +0000 Subject: [PATCH 5/7] update method name --- test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs b/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs index e536317333a..fecedfc5f68 100644 --- a/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs +++ b/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs @@ -593,7 +593,7 @@ public async Task UninstallTopLevelPackageFromUI() // Assert VisualStudio.AssertNoErrors(); - uiwindow.AssertPackageListIsNullIninsatlltab(); + uiwindow.AssertPackageListIsNullOrEmpty(); CommonUtility.AssertPackageReferenceDoesNotExist(VisualStudio, project, TestPackageName, Logger); } From 39c24275a8c1ea304f85038f2ad530011dc83dd1 Mon Sep 17 00:00:00 2001 From: Cici Li Date: Mon, 25 Nov 2024 06:49:29 +0000 Subject: [PATCH 6/7] add search public fields test case --- .../NuGet.Tests.Apex.Daily/NuGetUITestCase.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs b/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs index fecedfc5f68..680b33b8cec 100644 --- a/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs +++ b/test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs @@ -531,6 +531,41 @@ public async Task SearchTopLevelPackageInInstalledTabFromUI() uiwindow.AssertPackageNameAndType(TestPackageName, NuGet.VisualStudio.PackageLevel.TopLevel); } + [TestMethod] + [Timeout(DefaultTimeout)] + public async Task SearchTopLevelAndTransitivePackagePublicFieldInInstalledTabFromUI() + { + // Arrange + var transitivePackageName = "Contoso.B"; + await CommonUtility.CreateDependenciesPackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1, transitivePackageName, TestPackageVersionV1); + + NuGetApexTestService nugetTestService = GetNuGetTestService(); + + var solutionService = VisualStudio.Get(); + solutionService.CreateEmptySolution("TestSolution", _pathContext.SolutionRoot); + var project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.NetCoreClassLib, "TestProject"); + VisualStudio.ClearOutputWindow(); + solutionService.SaveAll(); + + CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); + + var uiwindow = nugetTestService.GetUIWindowfromProject(project); + uiwindow.InstallPackageFromUI(TestPackageName, TestPackageVersionV1); + solutionService.Build(); + + CommonUtility.AssertPackageReferenceExists(VisualStudio, project, TestPackageName, TestPackageVersionV1, Logger); + uiwindow.AssertPackageNameAndType(TestPackageName, NuGet.VisualStudio.PackageLevel.TopLevel); + uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.Transitive); + + // Act + uiwindow.SearchPackageFromUI("Contoso"); + + // Assert + VisualStudio.AssertNoErrors(); + uiwindow.AssertPackageNameAndType(TestPackageName, NuGet.VisualStudio.PackageLevel.TopLevel); + uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.Transitive); + } + [TestMethod] [Timeout(DefaultTimeout)] public async Task InstallTopLevelPackageFromUI() From 0fa446f72f3e82374b2f53aed542f776fb92afb0 Mon Sep 17 00:00:00 2001 From: Cici Li Date: Tue, 26 Nov 2024 09:09:36 +0000 Subject: [PATCH 7/7] Update the assert method --- .../NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs b/test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs index 96410b6ad1c..2f24e25c9b0 100644 --- a/test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs +++ b/test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetUIProjectTestExtension.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using System.Linq; using FluentAssertions; -using Microsoft.TeamFoundation.Common; using Microsoft.Test.Apex.Services; using NuGet.PackageManagement.UI; using NuGet.PackageManagement.UI.TestContract; @@ -77,9 +76,9 @@ public void AssertPackageNameAndType(string packageId, PackageLevel packageLevel package.Id.Should().Be(packageId); } - public bool AssertPackageListIsNullOrEmpty() + public void AssertPackageListIsNullOrEmpty() { - return _uiproject.PackageItems.IsNullOrEmpty(); + _uiproject.GetPackageItemsOnInstalledTab().Should().BeNullOrEmpty("Package items list isn't null or empty on installed tab."); ; } public bool InstallPackageFromUI(string packageId, string version)