Skip to content

Commit 36e1ede

Browse files
Copilotnkolev92
andauthored
Remove InstallPackageFromPMC_TriggersNuGetCacheUpdatedEventAsync test and revert SolutionManager property
Agent-Logs-Url: https://github.com/NuGet/NuGet.Client/sessions/4ff4fd9e-2c3b-4f98-bd0d-250dd8408f55 Co-authored-by: nkolev92 <[email protected]>
1 parent 5a68ca1 commit 36e1ede

3 files changed

Lines changed: 32 additions & 47 deletions

File tree

test/EndToEnd/tests/NetCoreProjectTest.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
# VSSolutionManager and ProjectSystemCache event test for .net core
2+
function Test-NetCoreProjectSystemCacheUpdateEvent {
3+
4+
# Arrange
5+
$projectA = New-NetCoreConsoleApp
6+
Build-Solution
7+
Assert-NetCoreProjectCreation $projectA
8+
9+
$componentModel = Get-VSComponentModel
10+
$solutionManager = $componentModel.GetService([NuGet.PackageManagement.ISolutionManager])
11+
12+
$cacheEvent = $null
13+
14+
Get-Event | Remove-Event
15+
Register-ObjectEvent -InputObject $solutionManager -EventName AfterNuGetCacheUpdated -SourceIdentifier SolutionManagerCacheUpdated
16+
17+
Try
18+
{
19+
# Act
20+
$projectA | Install-Package Newtonsoft.Json -Version '13.0.1'
21+
22+
$cacheEvent = Wait-Event -SourceIdentifier SolutionManagerCacheUpdated -TimeoutSec 10
23+
}
24+
Finally
25+
{
26+
Unregister-Event -SourceIdentifier SolutionManagerCacheUpdated
27+
}
28+
29+
# Assert
30+
Assert-NotNull $cacheEvent -Message "Cache update event should've been raised"
31+
}
32+
133
function Test-NetCoreTargetFrameworksVSandMSBuildNoOp {
234
[SkipTest('https://github.com/NuGet/Home/issues/13003')]
335
param ()

test/NuGet.Tests.Apex/NuGet.Tests.Apex/Apex/NuGetApexTestService.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
using Microsoft.VisualStudio.Shell.Interop;
1919
using Microsoft.VisualStudio.Shell.ServiceBroker;
2020
using NuGet.Console.TestContract;
21-
using NuGet.PackageManagement;
2221
using NuGet.PackageManagement.UI.TestContract;
2322
using NuGet.SolutionRestoreManager;
2423
using NuGet.Versioning;
@@ -57,11 +56,6 @@ protected internal IVsSolutionRestoreStatusProvider SolutionRestoreStatusProvide
5756

5857
protected internal IVsPathContextProvider2 PathContextProvider2 => VisualStudioObjectProviders.GetComponentModelService<IVsPathContextProvider2>();
5958

60-
/// <summary>
61-
/// Gets the NuGet ISolutionManager
62-
/// </summary>
63-
protected internal ISolutionManager SolutionManager => VisualStudioObjectProviders.GetComponentModelService<ISolutionManager>();
64-
6559
/// <summary>
6660
/// Wait for all nominations and auto restore to complete.
6761
/// This uses an Action to log since the xunit logger is not fully serializable.

test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NetCoreProjectTestCase.cs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
using System;
21
using System.Collections.Generic;
32
using System.Diagnostics;
43
using System.IO;
5-
using System.Threading;
64
using System.Threading.Tasks;
75
using Microsoft.Test.Apex.VisualStudio.Solution;
86
using Microsoft.VisualStudio.TestTools.UnitTesting;
9-
using NuGet.PackageManagement;
107

118
namespace NuGet.Tests.Apex
129
{
@@ -237,44 +234,6 @@ public async Task WithSourceMappingEnabled_InstallPackageFromPMUIAndNoSourcesFou
237234
}
238235
}
239236

240-
// Migrated from Test-NetCoreProjectSystemCacheUpdateEvent in NetCoreProjectTest.ps1
241-
[TestMethod]
242-
[Timeout(DefaultTimeout)]
243-
public async Task InstallPackageFromPMC_TriggersNuGetCacheUpdatedEventAsync()
244-
{
245-
// Arrange
246-
using var testContext = new ApexTestContext(VisualStudio, ProjectTemplate.NetCoreConsoleApp, Logger, addNetStandardFeeds: true);
247-
248-
var packageName = "TestPackage";
249-
var packageVersion = "1.0.0";
250-
await CommonUtility.CreatePackageInSourceAsync(testContext.PackageSource, packageName, packageVersion);
251-
252-
testContext.SolutionService.Build();
253-
testContext.NuGetApexTestService.WaitForAutoRestore();
254-
255-
// Subscribe to the ISolutionManager.AfterNuGetCacheUpdated event
256-
using var cacheUpdatedEvent = new ManualResetEventSlim(false);
257-
var solutionManager = testContext.NuGetApexTestService.SolutionManager;
258-
void OnAfterNuGetCacheUpdated(object sender, NuGetEventArgs<string> e) => cacheUpdatedEvent.Set();
259-
solutionManager.AfterNuGetCacheUpdated += OnAfterNuGetCacheUpdated;
260-
261-
try
262-
{
263-
// Act
264-
var nugetConsole = GetConsole(testContext.Project);
265-
nugetConsole.InstallPackageFromPMC(packageName, packageVersion);
266-
267-
// Assert
268-
Assert.IsTrue(
269-
cacheUpdatedEvent.Wait(TimeSpan.FromSeconds(10)),
270-
"Cache update event should have been raised after package install.");
271-
}
272-
finally
273-
{
274-
solutionManager.AfterNuGetCacheUpdated -= OnAfterNuGetCacheUpdated;
275-
}
276-
}
277-
278237
// Migrated from Test-NetCoreVSandMSBuildNoOp in NetCoreProjectTest.ps1
279238
[TestMethod]
280239
[Timeout(DefaultTimeout)]

0 commit comments

Comments
 (0)