Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new test cases for Transitive Package into NuGet.Client-VSDaily Tests pipeline #6148

Merged
merged 7 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions test/NuGet.Tests.Apex/NuGet.Tests.Apex.Daily/NuGetUITestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,141 @@ public async Task Uninstall_WithMultiplePackagesThatDependOnEachOther_PackageGoe
uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.Transitive);
}

[TestMethod]
[Timeout(DefaultTimeout)]
public async Task SearchTopLevelPackageInInstalledTabFromUI()
{
// Arrange
var transitivePackageName = "Contoso.B";
await CommonUtility.CreateDependenciesPackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1, transitivePackageName, TestPackageVersionV1);

NuGetApexTestService nugetTestService = GetNuGetTestService();

var solutionService = VisualStudio.Get<SolutionService>();
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);
donnie-msft marked this conversation as resolved.
Show resolved Hide resolved

// Act
uiwindow.SearchPackageFromUI(TestPackageName);

// Assert
VisualStudio.AssertNoErrors();
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>();
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()
{
// Arrange
var transitivePackageName = "Contoso.B";
await CommonUtility.CreateDependenciesPackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1, transitivePackageName, TestPackageVersionV1);

NuGetApexTestService nugetTestService = GetNuGetTestService();

var solutionService = VisualStudio.Get<SolutionService>();
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 UninstallTopLevelPackageFromUI()
{
// Arrange
var transitivePackageName = "Contoso.B";
await CommonUtility.CreateDependenciesPackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1, transitivePackageName, TestPackageVersionV1);

NuGetApexTestService nugetTestService = GetNuGetTestService();

var solutionService = VisualStudio.Get<SolutionService>();
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.AssertPackageListIsNullOrEmpty();
CommonUtility.AssertPackageReferenceDoesNotExist(VisualStudio, project, TestPackageName, Logger);
}

[TestMethod]
[DataRow(ProjectTemplate.NetCoreConsoleApp)]
[DataRow(ProjectTemplate.ConsoleApplication)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public void AssertPackageNameAndType(string packageId, PackageLevel packageLevel
package.Id.Should().Be(packageId);
}

public void AssertPackageListIsNullOrEmpty()
{
_uiproject.GetPackageItemsOnInstalledTab().Should().BeNullOrEmpty("Package items list isn't null or empty on installed tab."); ;
}

public bool InstallPackageFromUI(string packageId, string version)
{
Stopwatch sw = Stopwatch.StartNew();
Expand Down