From 8a86dee74cb9f9787cbf1419ddac580bc3687d0d Mon Sep 17 00:00:00 2001 From: "Sue Su (BEYONDSOFT CONSULTING INC)" Date: Tue, 25 Jun 2024 08:22:42 +0000 Subject: [PATCH] remove duplicate tests --- .../NetCoreProjectTestCase.cs | 100 --- .../NuGetConsoleTestCase.cs | 360 ----------- .../NuGetEndToEndTests/NuGetUITestCase.cs | 607 ------------------ 3 files changed, 1067 deletions(-) diff --git a/test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NetCoreProjectTestCase.cs b/test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NetCoreProjectTestCase.cs index f29fa315958..58d71f7600d 100644 --- a/test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NetCoreProjectTestCase.cs +++ b/test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NetCoreProjectTestCase.cs @@ -245,106 +245,6 @@ public async Task WithSourceMappingEnabled_InstallPackageFromPMUIAndNoSourcesFou } } - [DataTestMethod] - [DynamicData(nameof(GetNetCoreTemplates), DynamicDataSourceType.Method)] - [Timeout(DefaultTimeout)] - public async Task InstallPackageToNetCoreProjectFromUI(ProjectTemplate projectTemplate) - { - EnsureVisualStudioHost(); - - using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, Logger, addNetStandardFeeds: true)) - { - // Arrange - var packageName = "NetCoreInstallTestPackage"; - var packageVersion = "1.0.0"; - await CommonUtility.CreatePackageInSourceAsync(testContext.PackageSource, packageName, packageVersion); - - VisualStudio.AssertNoErrors(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - var nugetTestService = GetNuGetTestService(); - var uiwindow = nugetTestService.GetUIWindowfromProject(testContext.Project); - uiwindow.InstallPackageFromUI(packageName, packageVersion); - - // Assert - VisualStudio.AssertNuGetOutputDoesNotHaveErrors(); - CommonUtility.AssertPackageReferenceExists(VisualStudio, testContext.Project, packageName, packageVersion, Logger); - } - } - - [DataTestMethod] - [DynamicData(nameof(GetNetCoreTemplates), DynamicDataSourceType.Method)] - [Timeout(DefaultTimeout)] - public async Task UpdatePackageToNetCoreProjectFromUI(ProjectTemplate projectTemplate) - { - EnsureVisualStudioHost(); - - using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, Logger, addNetStandardFeeds: true)) - { - // Arrange - var packageName = "NetCoreUpdateTestPackage"; - var packageVersion1 = "1.0.0"; - var packageVersion2 = "2.0.0"; - - await CommonUtility.CreatePackageInSourceAsync(testContext.PackageSource, packageName, packageVersion1); - await CommonUtility.CreatePackageInSourceAsync(testContext.PackageSource, packageName, packageVersion2); - - VisualStudio.AssertNoErrors(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - var nugetTestService = GetNuGetTestService(); - var uiwindow = nugetTestService.GetUIWindowfromProject(testContext.Project); - uiwindow.InstallPackageFromUI(packageName, packageVersion1); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - uiwindow.UpdatePackageFromUI(packageName, packageVersion2); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - // Assert - VisualStudio.AssertNuGetOutputDoesNotHaveErrors(); - CommonUtility.AssertPackageReferenceExists(VisualStudio, testContext.Project, packageName, packageVersion2, Logger); - } - } - - [DataTestMethod] - [DynamicData(nameof(GetNetCoreTemplates), DynamicDataSourceType.Method)] - [Timeout(DefaultTimeout)] - public async Task UninstallPackageFromNetCoreProjectFromUI(ProjectTemplate projectTemplate) - { - EnsureVisualStudioHost(); - - using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, Logger, addNetStandardFeeds: true)) - { - // Arrange - var packageName = "NetCoreUninstallTestPackage"; - var packageVersion = "1.0.0"; - - await CommonUtility.CreatePackageInSourceAsync(testContext.PackageSource, packageName, packageVersion); - - VisualStudio.AssertNoErrors(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - var nugetTestService = GetNuGetTestService(); - var uiwindow = nugetTestService.GetUIWindowfromProject(testContext.Project); - uiwindow.InstallPackageFromUI(packageName, packageVersion); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - uiwindow.UninstallPackageFromUI(packageName); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - // Assert - VisualStudio.AssertNuGetOutputDoesNotHaveErrors(); - CommonUtility.AssertPackageReferenceDoesNotExist(VisualStudio, testContext.Project, packageName, Logger); - } - } - // There is a bug with VS or Apex where NetCoreConsoleApp and NetCoreClassLib create netcore 2.1 projects that are not supported by the sdk // Commenting out any NetCoreConsoleApp or NetCoreClassLib template and swapping it for NetStandardClassLib as both are package ref. diff --git a/test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NuGetConsoleTestCase.cs b/test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NuGetConsoleTestCase.cs index b7cf99d7ab5..a6c1abcfcc2 100644 --- a/test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NuGetConsoleTestCase.cs +++ b/test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NuGetConsoleTestCase.cs @@ -693,366 +693,6 @@ public async Task UpdatePackageForPR_PackageNamespace_WithMultipleFeedsWithIdent solutionService.Save(); } - [DataTestMethod] - [DynamicData(nameof(GetNetCoreTemplates), DynamicDataSourceType.Method)] - [Timeout(DefaultTimeout)] - public async Task VerifyCacheFileInsideObjFolder(ProjectTemplate projectTemplate) - { - // Arrange - EnsureVisualStudioHost(); - - using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, Logger, addNetStandardFeeds: true)) - { - var packageName = "VerifyCacheFilePackage"; - var packageVersion = "1.0.0"; - await CommonUtility.CreatePackageInSourceAsync(testContext.PackageSource, packageName, packageVersion); - var nugetConsole = GetConsole(testContext.Project); - - //Act - nugetConsole.InstallPackageFromPMC(packageName, packageVersion); - FileInfo CacheFilePath = CommonUtility.GetCacheFilePath(testContext.Project.FullPath); - - // Assert - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - CommonUtility.WaitForFileExists(CacheFilePath); - - testContext.Project.Rebuild(); - CommonUtility.WaitForFileExists(CacheFilePath); - - testContext.Project.Clean(); - CommonUtility.WaitForFileNotExists(CacheFilePath); - } - } - - [DataTestMethod] - [DataRow(ProjectTemplate.ClassLibrary, "PackageA", "1.0.0", "2.0.0", "PackageB", "1.0.1", "2.0.1")] - [DataRow(ProjectTemplate.NetStandardClassLib, "PackageC", "1.0.0", "2.0.0", "PackageD", "1.1.0", "2.2.0")] - [Timeout(DefaultTimeout)] - public async Task UpdateAllPackagesInPMC(ProjectTemplate projectTemplate, string packageName1, string packageVersion1, string packageVersion2, string packageName2, string packageVersion3, string packageVersion4) - { - EnsureVisualStudioHost(); - using (var simpleTestPathContext = new SimpleTestPathContext()) - { - // Arrange - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, packageName1, packageVersion1); - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, packageName1, packageVersion2); - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, packageName2, packageVersion3); - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, packageName2, packageVersion4); - - using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, Logger, addNetStandardFeeds: true, simpleTestPathContext: simpleTestPathContext)) - { - var solutionService = VisualStudio.Get(); - var nugetConsole = GetConsole(testContext.Project); - - // Act - nugetConsole.InstallPackageFromPMC(packageName1, packageVersion1); - nugetConsole.InstallPackageFromPMC(packageName2, packageVersion3); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - nugetConsole.Execute("update-package"); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - // Assert - if (projectTemplate.ToString().Equals("ClassLibrary")) - { - CommonUtility.AssertPackageInPackagesConfig(VisualStudio, testContext.Project, packageName1, packageVersion2, Logger); - CommonUtility.AssertPackageInPackagesConfig(VisualStudio, testContext.Project, packageName2, packageVersion4, Logger); - } - else - { - CommonUtility.AssertPackageReferenceExists(VisualStudio, testContext.Project, packageName1, packageVersion2, Logger); - CommonUtility.AssertPackageReferenceExists(VisualStudio, testContext.Project, packageName2, packageVersion4, Logger); - } - VisualStudio.AssertNuGetOutputDoesNotHaveErrors(); - Assert.IsTrue(VisualStudio.HasNoErrorsInOutputWindows()); - } - } - } - - [DataTestMethod] - [DynamicData(nameof(GetMauiTemplates), DynamicDataSourceType.Method)] - [Timeout(DefaultTimeout)] - public async Task InstallPackageForMauiProjectInPMC(ProjectTemplate projectTemplate) - { - EnsureVisualStudioHost(); - using (var simpleTestPathContext = new SimpleTestPathContext()) - { -                // Arrange -                var packageName = "IOSTestPackage"; - var v100 = "1.0.0"; - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, packageName, v100); - simpleTestPathContext.Settings.AddSource(NuGetConstants.NuGetHostName, NuGetConstants.V3FeedUrl); - - using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, Logger, simpleTestPathContext: simpleTestPathContext)) - { - VisualStudio.AssertNoErrors(); - var solutionService = VisualStudio.Get(); - testContext.SolutionService.Build(); - - // Act - var nugetConsole = GetConsole(testContext.Project); - - nugetConsole.InstallPackageFromPMC(packageName, v100); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - // Assert - VisualStudio.AssertNuGetOutputDoesNotHaveErrors(); - CommonUtility.AssertPackageInAssetsFile(VisualStudio, testContext.Project, packageName, v100, Logger); - Assert.IsTrue(VisualStudio.HasNoErrorsInOutputWindows()); - } - } - } - - [DataTestMethod] - [DynamicData(nameof(GetMauiTemplates), DynamicDataSourceType.Method)] - [Timeout(DefaultTimeout)] - public async Task UpdatePackageForMauiProjectInPMC(ProjectTemplate projectTemplate) - { - EnsureVisualStudioHost(); - using (var simpleTestPathContext = new SimpleTestPathContext()) - { - // Arrange - var packageName = "IOSTestPackage"; - var v100 = "1.0.0"; - var v200 = "2.0.0"; - - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, packageName, v100); - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, packageName, v200); - simpleTestPathContext.Settings.AddSource(NuGetConstants.NuGetHostName, NuGetConstants.V3FeedUrl); - - using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, Logger, simpleTestPathContext: simpleTestPathContext)) - { - VisualStudio.AssertNoErrors(); - var solutionService = VisualStudio.Get(); - testContext.SolutionService.Build(); - - // Act - var nugetConsole = GetConsole(testContext.Project); - - nugetConsole.InstallPackageFromPMC(packageName, v100); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - nugetConsole.UpdatePackageFromPMC(packageName, v200); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - // Assert - VisualStudio.AssertNuGetOutputDoesNotHaveErrors(); - CommonUtility.AssertPackageInAssetsFile(VisualStudio, testContext.Project, packageName, v200, Logger); - Assert.IsTrue(VisualStudio.HasNoErrorsInOutputWindows()); - } - } - } - - [DataTestMethod] - [DynamicData(nameof(GetMauiTemplates), DynamicDataSourceType.Method)] - [Timeout(DefaultTimeout)] - public async Task UninstallPackageForMauiProjectInPMC(ProjectTemplate projectTemplate) - { - EnsureVisualStudioHost(); - using (var simpleTestPathContext = new SimpleTestPathContext()) - { - //Arrange - var PackageName = "IOSTestPackage"; - var v100 = "1.0.0"; - - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, PackageName, v100); - simpleTestPathContext.Settings.AddSource(NuGetConstants.NuGetHostName, NuGetConstants.V3FeedUrl); - - using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, Logger, simpleTestPathContext: simpleTestPathContext)) - { - VisualStudio.AssertNoErrors(); - var solutionService = VisualStudio.Get(); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - // Act - var nugetConsole = GetConsole(testContext.Project); - - nugetConsole.InstallPackageFromPMC(PackageName, v100); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - nugetConsole.UninstallPackageFromPMC(PackageName); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - //Asset - VisualStudio.AssertNuGetOutputDoesNotHaveErrors(); - CommonUtility.AssertPackageNotInAssetsFile(VisualStudio, testContext.Project, PackageName, v100, Logger); - Assert.IsTrue(VisualStudio.HasNoErrorsInOutputWindows()); - } - } - } - - [DataTestMethod] - [DataRow(ProjectTemplate.WCFServiceApplication)] - [DataRow(ProjectTemplate.NetStandardClassLib)] - [Timeout(DefaultTimeout)] - - public async Task InstallLatestPackageInPMC(ProjectTemplate projectTemplate) - { - EnsureVisualStudioHost(); - using (var simpleTestPathContext = new SimpleTestPathContext()) - { - // Arrange - var packageName = "InstallLatestInPMC"; - var v100 = "1.0.0"; - var v200 = "2.0.0"; - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, packageName, v100); - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, packageName, v200); - - using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, Logger, addNetStandardFeeds: true, simpleTestPathContext: simpleTestPathContext)) - { - var solutionService = VisualStudio.Get(); - var nugetConsole = GetConsole(testContext.Project); - - // Act - nugetConsole.Execute("install-package InstallLatestInPMC"); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - - // Assert - if (projectTemplate.ToString().Equals("WCFServiceApplication")) - { - CommonUtility.AssertPackageInPackagesConfig(VisualStudio, testContext.Project, packageName, v200, Logger); - } - else - { - CommonUtility.AssertPackageReferenceExists(VisualStudio, testContext.Project, packageName, v200, Logger); - } - VisualStudio.AssertNuGetOutputDoesNotHaveErrors(); - Assert.IsTrue(VisualStudio.HasNoErrorsInOutputWindows()); - } - } - } - - [DataTestMethod] - [DynamicData(nameof(GetPackagesConfigTemplates), DynamicDataSourceType.Method)] - [Timeout(DefaultTimeout)] - public void VerifyInitScriptsExecution(ProjectTemplate projectTemplate) - { - EnsureVisualStudioHost(); - using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, Logger)) - { - // Arrange - SolutionService solutionService = VisualStudio.Get(); - var nugetConsole = GetConsole(testContext.Project); - var source = NuGetConstants.V3FeedUrl; - - // Act - nugetConsole.Execute($"install-package EntityFramework -source {source} -Verbose"); - - // Assert - Assert.IsTrue(nugetConsole.IsMessageFoundInPMC("init.ps1"), "The init.ps1 script in TestProject was not executed when the EntityFramework package was installed"); - - // Act - nugetConsole.Clear(); - nugetConsole.Execute($"install-package jquery -source {source} -Verbose"); - - // Assert - Assert.IsTrue(nugetConsole.IsMessageFoundInPMC("install.ps1"), "The install.ps1 script in TestProject was not executed when the jquery package was installed."); - - // Act - nugetConsole.Clear(); - nugetConsole.Execute($"install-package entityframework.sqlservercompact -source {source} -Verbose"); - - // Assert - // nugetConsole.IsMessageFoundInPMC is case sensitive. - Assert.IsTrue(nugetConsole.IsMessageFoundInPMC("Install.ps1"), "The Install.ps1 script in TestProject was not executed when the Entityframework.sqlservercompact package was installed."); - } - } - - [DataTestMethod] - [Timeout(DefaultTimeout)] - public async Task VerifyCmdFindPackageExactMatchInPMC() - { - EnsureVisualStudioHost(); - using (var simpleTestPathContext = new SimpleTestPathContext()) - { - // Arrange - var PackageName = "TestPackage"; - var v100 = "1.0.0"; - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, PackageName, v100); - - using (var testContext = new ApexTestContext(VisualStudio, ProjectTemplate.NetCoreConsoleApp, Logger, addNetStandardFeeds: true, simpleTestPathContext: simpleTestPathContext)) - { - SolutionService solutionService = VisualStudio.Get(); - var nugetConsole = GetConsole(testContext.Project); - - // Act - nugetConsole.Execute($"find-package {PackageName} -ExactMatch"); - - // Assert - string PMCText = nugetConsole.GetText(); - PMCText.Should().Contain(PackageName); - PMCText.Should().Contain(v100); - } - } - } - - [DataTestMethod] - [Timeout(DefaultTimeout)] - public async Task VerifyCmdGetPackageUpdateInPMC() - { - EnsureVisualStudioHost(); - using (var simpleTestPathContext = new SimpleTestPathContext()) - { - // Arrange - var packageName = "TestPackage"; - var v100 = "1.0.0"; - var v200 = "2.0.0"; - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, packageName, v100); - await CommonUtility.CreatePackageInSourceAsync(simpleTestPathContext.PackageSource, packageName, v200); - - using (var testContext = new ApexTestContext(VisualStudio, ProjectTemplate.NetCoreConsoleApp, Logger, addNetStandardFeeds: true, simpleTestPathContext: simpleTestPathContext)) - { - // Arrange - SolutionService solutionService = VisualStudio.Get(); - var nugetConsole = GetConsole(testContext.Project); - - nugetConsole.InstallPackageFromPMC(packageName, v100); - testContext.SolutionService.Build(); - testContext.NuGetApexTestService.WaitForAutoRestore(); - nugetConsole.Clear(); - - // Act - nugetConsole.Execute("get-package -update"); - - // Assert - string PMCText = nugetConsole.GetText(); - PMCText.Should().Contain(v200); - } - } - } - - [DataTestMethod] - [Timeout(DefaultTimeout)] - public void VerifyCmdGetProjectInPMC() - { - EnsureVisualStudioHost(); - using (var testContext = new ApexTestContext(VisualStudio, ProjectTemplate.ClassLibrary, Logger)) - { - // Arrange - SolutionService solutionService = VisualStudio.Get(); - var nugetConsole = GetConsole(testContext.Project); - - //Act - nugetConsole.Execute("Get-Project"); - - // Assert - string PMCText = nugetConsole.GetText(); - PMCText.Should().Contain(testContext.Project.Name); - PMCText.Should().Contain("C#"); - PMCText.Should().Contain(testContext.Project.FullPath); - } - } - [TestMethod] [Timeout(DefaultTimeout)] public async Task UpdatePackageForPR_PackageIdWithDifferentCase_UpdatesSuccessfully() diff --git a/test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NuGetUITestCase.cs b/test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NuGetUITestCase.cs index 811162fe9a8..270cf52e415 100644 --- a/test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NuGetUITestCase.cs +++ b/test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NuGetUITestCase.cs @@ -390,612 +390,5 @@ private static FileInfo GetPackagesConfigFile(ProjectTestExtension project) return new FileInfo(Path.Combine(projectFile.DirectoryName, "packages.config")); } - - [TestMethod] - [Timeout(DefaultTimeout)] - public void InstallPackageToWebSiteProjectFromUI() - { - // Arrange - EnsureVisualStudioHost(); - var dte = VisualStudio.Dte; - var solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution(); - var project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.WebSiteEmpty, ProjectTargetFramework.V48, "WebSiteEmpty"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - var nugetTestService = GetNuGetTestService(); - var uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI("log4net", "2.0.12"); - - // Assert - CommonUtility.AssertPackageInPackagesConfig(VisualStudio, project, "log4net", "2.0.12", Logger); - } - - [TestMethod] - [Timeout(DefaultTimeout)] - public void UpdateWebSitePackageFromUI() - { - // Arrange - EnsureVisualStudioHost(); - var dte = VisualStudio.Dte; - var solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution(); - var project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.WebSiteEmpty, ProjectTargetFramework.V48, "WebSiteEmpty"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - var nugetTestService = GetNuGetTestService(); - var uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI("log4net", "2.0.13"); - VisualStudio.ClearWindows(); - uiwindow.UpdatePackageFromUI("log4net", "2.0.15"); - - // Assert - CommonUtility.AssertPackageInPackagesConfig(VisualStudio, project, "log4net", "2.0.15", Logger); - } - - [TestMethod] - [Timeout(DefaultTimeout)] - public void UninstallWebSitePackageFromUI() - { - // Arrange - EnsureVisualStudioHost(); - var dte = VisualStudio.Dte; - var solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution(); - var project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.WebSiteEmpty, ProjectTargetFramework.V48, "WebSiteEmpty"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - var nugetTestService = GetNuGetTestService(); - var uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI("log4net", "2.0.15"); - VisualStudio.ClearWindows(); - uiwindow.UninstallPackageFromUI("log4net"); - - // Assert - CommonUtility.AssertPackageNotInPackagesConfig(VisualStudio, project, "log4net", Logger); - } - - [TestMethod] - [Timeout(DefaultTimeout)] - public async Task SearchPackageInBrowseTabFromUI() - { - // Arrange - var tabName = "Browse"; - await CommonUtility.CreatePackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1); - - NuGetApexTestService nugetTestService = GetNuGetTestService(); - - SolutionService solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution("TestSolution", _pathContext.SolutionRoot); - ProjectTestExtension project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.ClassLibrary, ProjectTargetFramework.V48, "TestProject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - - NuGetUIProjectTestExtension uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.SwitchTabToBrowse(); - uiwindow.SearchPackageFromUI(TestPackageName); - - // Assert - VisualStudio.AssertNoErrors(); - uiwindow.AssertSearchedPackageItem(tabName, TestPackageName); - } - - [TestMethod] - [Timeout(DefaultTimeout)] - public async Task SearchPackageInInstalledTabFromUI() - { - // Arrange - var TestPackageName2 = "Contoso.B"; - var tabName = "Installed"; - await CommonUtility.CreatePackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1); - await CommonUtility.CreatePackageInSourceAsync(_pathContext.PackageSource, TestPackageName2, TestPackageVersionV1); - CommonUtility.CreatePackage(TestPackageName2, TestPackageVersionV1); - - NuGetApexTestService nugetTestService = GetNuGetTestService(); - - SolutionService solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution("TestSolution", _pathContext.SolutionRoot); - ProjectTestExtension project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.ClassLibrary, ProjectTargetFramework.V48, "TestProject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - - NuGetUIProjectTestExtension uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI(TestPackageName, TestPackageVersionV1); - uiwindow.InstallPackageFromUI(TestPackageName2, TestPackageVersionV1); - uiwindow.SearchPackageFromUI(TestPackageName); - - // Assert - VisualStudio.AssertNoErrors(); - uiwindow.AssertSearchedPackageItem(tabName, TestPackageName, TestPackageVersionV1); - } - - [TestMethod] - [Timeout(DefaultTimeout)] - public async Task SearchPackageInUpdatesTabFromUI() - { - //Arrange - var tabName = "Updates"; - await CommonUtility.CreatePackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1); - await CommonUtility.CreatePackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV2); - - NuGetApexTestService nugetTestService = GetNuGetTestService(); - - SolutionService solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution("TestSolution", _pathContext.SolutionRoot); - ProjectTestExtension project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.ClassLibrary, ProjectTargetFramework.V48, "TestProject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - - NuGetUIProjectTestExtension uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI(TestPackageName, TestPackageVersionV1); - uiwindow.SwitchTabToUpdate(); - uiwindow.SearchPackageFromUI(TestPackageName); - - // Assert - VisualStudio.AssertNoErrors(); - uiwindow.AssertSearchedPackageItem(tabName, TestPackageName, TestPackageVersionV2); - } - - [DataTestMethod] - [DataRow(ProjectTemplate.ClassLibrary, "Newtonsoft.Json", "12.0.2")] - [DataRow(ProjectTemplate.NetCoreClassLib, "Newtonsoft.Json", "12.0.2")] - [Timeout(DefaultTimeout)] - public void InstallVulnerablePackageFromUI(ProjectTemplate projectTemplate, string packageName, string packageVersion) - { - // Arrange - EnsureVisualStudioHost(); - var solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution(); - var project = solutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, "TestProject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - var nugetTestService = GetNuGetTestService(); - var uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI(packageName, packageVersion); - solutionService.Build(); - - // Assert - CommonUtility.AssertInstalledPackageByProjectType(VisualStudio, projectTemplate, project, packageName, packageVersion, Logger); - uiwindow.AssertInstalledPackageVulnerable(); - } - - [DataTestMethod] - [DataRow(ProjectTemplate.ClassLibrary, "Newtonsoft.Json", "12.0.2", "13.0.1")] - [DataRow(ProjectTemplate.NetCoreClassLib, "Newtonsoft.Json", "12.0.2", "13.0.2")] - [Timeout(DefaultTimeout)] - public void UpdateVulnerablePackageFromUI(ProjectTemplate projectTemplate, string packageName, string packageVersion1, string packageVersion2) - { - // Arrange - EnsureVisualStudioHost(); - var solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution(); - var project = solutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, "TestProject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - var nugetTestService = GetNuGetTestService(); - var uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI(packageName, packageVersion1); - solutionService.Build(); - - // Assert - CommonUtility.AssertInstalledPackageByProjectType(VisualStudio, projectTemplate, project, packageName, packageVersion1, Logger); - uiwindow.AssertInstalledPackageVulnerable(); - - // Act - uiwindow.UpdatePackageFromUI(packageName, packageVersion2); - - // Assert - CommonUtility.AssertInstalledPackageByProjectType(VisualStudio, projectTemplate, project, packageName, packageVersion2, Logger); - uiwindow.AssertInstalledPackageNotVulnerable(); - } - - [DataTestMethod] - [DataRow(ProjectTemplate.ClassLibrary, "Newtonsoft.Json", "12.0.3")] - [DataRow(ProjectTemplate.NetCoreClassLib, "Newtonsoft.Json", "12.0.3")] - [Timeout(DefaultTimeout)] - public void UninstallVulnerablePackageFromUI(ProjectTemplate projectTemplate, string packageName, string packageVersion) - { - // Arrange - EnsureVisualStudioHost(); - var solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution(); - var project = solutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, "Testproject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - var nugetTestService = GetNuGetTestService(); - var uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI(packageName, packageVersion); - solutionService.Build(); - - // Assert - CommonUtility.AssertInstalledPackageByProjectType(VisualStudio, projectTemplate, project, packageName, packageVersion, Logger); - uiwindow.AssertInstalledPackageVulnerable(); - - // Act - VisualStudio.ClearWindows(); - uiwindow.UninstallPackageFromUI(packageName); - - // Assert - CommonUtility.AssertUninstalledPackageByProjectType(VisualStudio, projectTemplate, project, packageName, Logger); - } - - [DataTestMethod] - [DataRow(ProjectTemplate.ClassLibrary, "jquery", "3.5.0")] - [DataRow(ProjectTemplate.NetCoreClassLib, "jquery", "3.5.0")] - [Timeout(DefaultTimeout)] - public void InstallDeprecatedPackageFromUI(ProjectTemplate projectTemplate, string packageName, string packageVersion) - { - // Arrange - EnsureVisualStudioHost(); - var solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution(); - var project = solutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, "TestProject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - var nugetTestService = GetNuGetTestService(); - var uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI(packageName, packageVersion); - solutionService.Build(); - - // Assert - CommonUtility.AssertInstalledPackageByProjectType(VisualStudio, projectTemplate, project, packageName, packageVersion, Logger); - uiwindow.AssertInstalledPackageDeprecated(); - } - - [DataTestMethod] - [DataRow(ProjectTemplate.ClassLibrary, "jQuery", "3.5.0", "3.6.0")] - [DataRow(ProjectTemplate.NetCoreClassLib, "jQuery", "3.5.0", "3.6.3")] - [Timeout(DefaultTimeout)] - public void UpdateDeprecatedPackageFromUI(ProjectTemplate projectTemplate, string packageName, string packageVersion1, string packageVersion2) - { - // Arrange - EnsureVisualStudioHost(); - var solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution(); - var project = solutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, "TestProject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - var nugetTestService = GetNuGetTestService(); - var uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI(packageName, packageVersion1); - solutionService.Build(); - - // Assert - CommonUtility.AssertInstalledPackageByProjectType(VisualStudio, projectTemplate, project, packageName, packageVersion1, Logger); - uiwindow.AssertInstalledPackageDeprecated(); - - // Act - uiwindow.UpdatePackageFromUI(packageName, packageVersion2); - - // Assert - CommonUtility.AssertInstalledPackageByProjectType(VisualStudio, projectTemplate, project, packageName, packageVersion2, Logger); - uiwindow.AssertInstalledPackageNotDeprecated(); - } - - [DataTestMethod] - [DataRow(ProjectTemplate.ClassLibrary, "jQuery", "3.5.0")] - [DataRow(ProjectTemplate.NetCoreClassLib, "jQuery", "3.5.0")] - [Timeout(DefaultTimeout)] - public void UninstallDeprecatedPackageFromUI(ProjectTemplate projectTemplate, string packageName, string packageVersion) - { - // Arrange - EnsureVisualStudioHost(); - var solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution(); - var project = solutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, "Testproject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - var nugetTestService = GetNuGetTestService(); - var uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI(packageName, packageVersion); - solutionService.Build(); - - // Assert - CommonUtility.AssertInstalledPackageByProjectType(VisualStudio, projectTemplate, project, packageName, packageVersion, Logger); - uiwindow.AssertInstalledPackageDeprecated(); - - // Act - VisualStudio.ClearWindows(); - uiwindow.UninstallPackageFromUI(packageName); - - // Assert - CommonUtility.AssertUninstalledPackageByProjectType(VisualStudio, projectTemplate, project, packageName, Logger); - } - - [TestMethod] - [Timeout(DefaultTimeout)] - public async Task SearchTransitivePackageInInstalledTabFromUI() - { - // 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(transitivePackageName); - - // Assert - VisualStudio.AssertNoErrors(); - uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.Transitive); - } - - [TestMethod] - [Timeout(DefaultTimeout)] - public async Task InstallTransitivePackageFromUI() - { - // 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); - - var uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI(TestPackageName, TestPackageVersionV1); - solutionService.Build(); - - uiwindow.AssertPackageNameAndType(TestPackageName, NuGet.VisualStudio.PackageLevel.TopLevel); - uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.Transitive); - - // Act - uiwindow.InstallPackageFromUI(transitivePackageName, TestPackageVersionV1); - solutionService.Build(); - - // Assert - VisualStudio.AssertNoErrors(); - CommonUtility.AssertPackageReferenceExists(VisualStudio, project, transitivePackageName, TestPackageVersionV1, Logger); - uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.TopLevel); - } - - [TestMethod] - [Timeout(DefaultTimeout)] - public async Task Uninstall_WithMultiplePackagesThatDependOnEachOther_PackageGoesFromDirectToTransitive() - { - // 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(); - - uiwindow.AssertPackageNameAndType(TestPackageName, NuGet.VisualStudio.PackageLevel.TopLevel); - uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.Transitive); - - uiwindow.InstallPackageFromUI(transitivePackageName, TestPackageVersionV1); - solutionService.Build(); - - CommonUtility.AssertPackageReferenceExists(VisualStudio, project, transitivePackageName, TestPackageVersionV1, Logger); - uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.TopLevel); - - // Act - uiwindow.UninstallPackageFromUI(transitivePackageName); - solutionService.Build(); - - // Assert - VisualStudio.AssertNoErrors(); - CommonUtility.AssertPackageReferenceDoesNotExist(VisualStudio, project, transitivePackageName, Logger); - uiwindow.AssertPackageNameAndType(TestPackageName, NuGet.VisualStudio.PackageLevel.TopLevel); - uiwindow.AssertPackageNameAndType(transitivePackageName, NuGet.VisualStudio.PackageLevel.Transitive); - } - - [TestMethod] - [DataRow(ProjectTemplate.NetCoreConsoleApp)] - [DataRow(ProjectTemplate.ConsoleApplication)] - [Timeout(DefaultTimeout)] - public async Task VerifyRestorePackageByRestoreNuGetPackagesContextMenu(ProjectTemplate projectTemplate) - { - // Arrange - string packageFolderPath; - string installedPackageFolderPath; - - await CommonUtility.CreatePackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1); - - NuGetApexTestService nugetTestService = GetNuGetTestService(); - - var solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution("TestSolution", _pathContext.SolutionRoot); - var project = solutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, "TestProject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - - var uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI(TestPackageName, TestPackageVersionV1); - solutionService.Build(); - - if (projectTemplate.Equals(ProjectTemplate.NetCoreConsoleApp)) - { - packageFolderPath = _pathContext.UserPackagesFolder; - installedPackageFolderPath = Path.Combine(packageFolderPath, TestPackageName); - } - else - { - packageFolderPath = _pathContext.PackagesV2; - installedPackageFolderPath = Path.Combine(packageFolderPath, "Contoso.A.1.0.0"); - } - - Directory.Exists(installedPackageFolderPath).Should().BeTrue(); - - // Act - Directory.Delete(packageFolderPath, true); - Directory.Exists(packageFolderPath).Should().BeFalse(); - CommonUtility.RestoreNuGetPackages(VisualStudio, Logger); - - // Assert - CommonUtility.WaitForDirectoryExists(installedPackageFolderPath); - } - - [TestMethod] - [DataRow(ProjectTemplate.NetCoreConsoleApp)] - [DataRow(ProjectTemplate.ConsoleApplication)] - [Timeout(DefaultTimeout)] - public async Task VerifyPackageRestoredByBuilding(ProjectTemplate projectTemplate) - { - // Arrange - string packageFolderPath; - string installedPackageFolderPath; - await CommonUtility.CreatePackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1); - - NuGetApexTestService nugetTestService = GetNuGetTestService(); - - SolutionService solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution("TestSolution", _pathContext.SolutionRoot); - ProjectTestExtension project = solutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, "TestProject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - NuGetUIProjectTestExtension uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI(TestPackageName, TestPackageVersionV1); - - if (projectTemplate.Equals(ProjectTemplate.NetCoreConsoleApp)) - { - packageFolderPath = _pathContext.UserPackagesFolder; - installedPackageFolderPath = Path.Combine(packageFolderPath, TestPackageName); - } - else - { - packageFolderPath = _pathContext.PackagesV2; - installedPackageFolderPath = Path.Combine(packageFolderPath, "Contoso.A.1.0.0"); - } - - Directory.Exists(installedPackageFolderPath).Should().BeTrue(); - - // Act - Directory.Delete(packageFolderPath, true); - Directory.Exists(packageFolderPath).Should().BeFalse(); - solutionService.Build(); - - // Assert - Directory.Exists(installedPackageFolderPath).Should().BeTrue(); - } - - - [DataTestMethod] - [Timeout(DefaultTimeout)] - public void VerifyPackageNotRestoredAfterDisablingPackageRestore() - { - // Arrange - EnsureVisualStudioHost(); - - SolutionService solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution("TestSolution", _pathContext.SolutionRoot); - solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.MauiClassLibrary, "TestProject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - // Act - _pathContext.Settings.DisableAutoRestore(); - CommonUtility.RestoreNuGetPackages(VisualStudio, Logger); - VisualStudio.ObjectModel.Shell.ToolWindows.ErrorHub.ShowErrors(); - - // Assert - VisualStudio.AssertErrorListContainsSpecificError("NuGet restore is currently disabled."); - } - - [DataTestMethod] - [Timeout(DefaultTimeout)] - public async Task VerifyPackageNotRestoredAfterDisablingAutomaticInPackageRestoreSection() - { - // Arrange - NuGetApexTestService nugetTestService = GetNuGetTestService(); - - await CommonUtility.CreatePackageInSourceAsync(_pathContext.PackageSource, TestPackageName, TestPackageVersionV1); - - SolutionService solutionService = VisualStudio.Get(); - solutionService.CreateEmptySolution("TestSolution", _pathContext.SolutionRoot); - ProjectTestExtension project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.ConsoleApplication, "TestProject"); - VisualStudio.ClearOutputWindow(); - solutionService.SaveAll(); - - CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, Logger); - NuGetUIProjectTestExtension uiwindow = nugetTestService.GetUIWindowfromProject(project); - uiwindow.InstallPackageFromUI(TestPackageName, TestPackageVersionV1); - - _pathContext.Settings.DisableAutomaticInPackageRestoreSection(); - - var installedPackageFolderPath = Path.Combine(_pathContext.PackagesV2, "Contoso.A.1.0.0"); - Directory.Exists(installedPackageFolderPath).Should().BeTrue(); - Directory.Delete(installedPackageFolderPath, true); - - // Act - solutionService.Build(); - - // Assert - VisualStudio.AssertNuGetOutputDoesNotHaveErrors(); - CommonUtility.WaitForDirectoryNotExists(installedPackageFolderPath); - } } }