Skip to content

Commit a42f952

Browse files
authored
Migrate NetCore E2E tests from PowerShell to Apex (#7246)
1 parent ae4971f commit a42f952

6 files changed

Lines changed: 11 additions & 121 deletions

File tree

test/EndToEnd/ProjectTemplates/PackageReferenceClassLibrary.zip/ClassLibrary1.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>$safeprojectname$</RootNamespace>
1111
<AssemblyName>$safeprojectname$</AssemblyName>
12-
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
1515
</PropertyGroup>

test/EndToEnd/ProjectTemplates/PackageReferenceClassLibrary.zip/ProjectTemplate.vstemplate

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Name>PackageReferenceClassLibrary</Name>
55
<Description>Template for class library projects</Description>
66
<ProjectType>CSharp</ProjectType>
7-
<RequiredFrameworkVersion>4.6</RequiredFrameworkVersion>
7+
<RequiredFrameworkVersion>4.8</RequiredFrameworkVersion>
88
<SortOrder>1000</SortOrder>
99
<CreateNewFolder>true</CreateNewFolder>
1010
<DefaultName>ClassLibraryPR</DefaultName>

test/EndToEnd/ProjectTemplates/PackageReferenceClassLibraryWithLockFile.zip/ClassLibrary1.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>$safeprojectname$</RootNamespace>
1111
<AssemblyName>$safeprojectname$</AssemblyName>
12-
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
1515
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>

test/EndToEnd/ProjectTemplates/PackageReferenceClassLibraryWithLockFile.zip/ProjectTemplate.vstemplate

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Name>PackageReferenceClassLibrary</Name>
55
<Description>Template for class library projects</Description>
66
<ProjectType>CSharp</ProjectType>
7-
<RequiredFrameworkVersion>4.6</RequiredFrameworkVersion>
7+
<RequiredFrameworkVersion>4.8</RequiredFrameworkVersion>
88
<SortOrder>1000</SortOrder>
99
<CreateNewFolder>true</CreateNewFolder>
1010
<DefaultName>ClassLibraryPR</DefaultName>

test/EndToEnd/tests/NetCoreProjectTest.ps1

Lines changed: 7 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,3 @@
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-
33-
function Test-NetCoreConsoleAppClean {
34-
35-
# Arrange & Act
36-
$project = New-NetCoreConsoleApp ConsoleApp
37-
38-
Build-Solution
39-
40-
Assert-ProjectCacheFileExists $project
41-
42-
#Act
43-
Clean-Solution
44-
45-
#Assert
46-
Assert-ProjectCacheFileNotExists $project
47-
}
48-
49-
function Test-NetCoreConsoleAppRebuildDoesNotDeleteCacheFile {
50-
# Arrange & Act
51-
$project = New-NetCoreConsoleApp ConsoleApp
52-
Build-Solution
53-
54-
Assert-ProjectCacheFileExists $project
55-
56-
AdviseSolutionEvents
57-
58-
#Act
59-
Rebuild-Solution
60-
61-
WaitUntilRebuildCompleted
62-
UnadviseSolutionEvents
63-
64-
#Assert
65-
Assert-ProjectCacheFileExists $project
66-
}
67-
681
function Test-NetCoreVSandMSBuildNoOp {
692
param ()
703

@@ -77,14 +10,14 @@ function Test-NetCoreVSandMSBuildNoOp {
7710

7811
#Act
7912

80-
$VSRestoreTimestamp =( [datetime](Get-ItemProperty -Path $cacheFile -Name LastWriteTime).lastwritetime).Ticks
13+
$VSRestoreTimestamp =( [datetime](Get-ItemProperty -Path $cacheFile -Name LastWriteTime).lastwritetime).Ticks
8114

8215
$MSBuildExe = Get-MSBuildExe
8316

8417
& "$MSBuildExe" /t:restore $project.FullName
8518
Assert-True ($LASTEXITCODE -eq 0)
8619

87-
$MsBuildRestoreTimestamp =( [datetime](Get-ItemProperty -Path $cacheFile -Name LastWriteTime).lastwritetime).Ticks
20+
$MsBuildRestoreTimestamp =( [datetime](Get-ItemProperty -Path $cacheFile -Name LastWriteTime).lastwritetime).Ticks
8821

8922
#Assert
9023
Assert-True ($MsBuildRestoreTimestamp -eq $VSRestoreTimestamp)
@@ -102,14 +35,14 @@ function Test-NetCoreTargetFrameworksVSandMSBuildNoOp {
10235

10336
#Act
10437

105-
$VSRestoreTimestamp =( [datetime](Get-ItemProperty -Path $cacheFile -Name LastWriteTime).lastwritetime).Ticks
38+
$VSRestoreTimestamp =( [datetime](Get-ItemProperty -Path $cacheFile -Name LastWriteTime).lastwritetime).Ticks
10639

10740
$MSBuildExe = Get-MSBuildExe
10841

10942
& "$MSBuildExe" /t:restore $project.FullName
11043
Assert-True ($LASTEXITCODE -eq 0)
11144

112-
$MsBuildRestoreTimestamp =( [datetime](Get-ItemProperty -Path $cacheFile -Name LastWriteTime).lastwritetime).Ticks
45+
$MsBuildRestoreTimestamp =( [datetime](Get-ItemProperty -Path $cacheFile -Name LastWriteTime).lastwritetime).Ticks
11346

11447
#Assert
11548
Assert-True ($MsBuildRestoreTimestamp -eq $VSRestoreTimestamp)
@@ -127,14 +60,14 @@ function Test-NetCoreMultipleTargetFrameworksVSandMSBuildNoOp {
12760

12861
#Act
12962

130-
$VSRestoreTimestamp =( [datetime](Get-ItemProperty -Path $cacheFile -Name LastWriteTime).lastwritetime).Ticks
63+
$VSRestoreTimestamp =( [datetime](Get-ItemProperty -Path $cacheFile -Name LastWriteTime).lastwritetime).Ticks
13164

13265
$MSBuildExe = Get-MSBuildExe
13366

13467
& "$MSBuildExe" /t:restore $project.FullName
13568
Assert-True ($LASTEXITCODE -eq 0)
13669

137-
$MsBuildRestoreTimestamp =( [datetime](Get-ItemProperty -Path $cacheFile -Name LastWriteTime).lastwritetime).Ticks
70+
$MsBuildRestoreTimestamp =( [datetime](Get-ItemProperty -Path $cacheFile -Name LastWriteTime).lastwritetime).Ticks
13871

13972
#Assert
14073
Assert-True ($MsBuildRestoreTimestamp -eq $VSRestoreTimestamp)
@@ -150,7 +83,7 @@ function Test-NetCoreToolsVSandMSBuildNoOp {
15083
$ToolsCacheFile = Get-ProjectToolsCacheFilePath $project
15184

15285
#Act
153-
$VSRestoreTimestamp =( [datetime](Get-ItemProperty -Path $ToolsCacheFile -Name LastWriteTime).lastwritetime).Ticks
86+
$VSRestoreTimestamp =( [datetime](Get-ItemProperty -Path $ToolsCacheFile -Name LastWriteTime).lastwritetime).Ticks
15487

15588
$MSBuildExe = Get-MSBuildExe
15689

test/EndToEnd/tests/ServicesTest.ps1

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,6 @@ function Test-PackageManagerServicesAreAvailableThroughMEF {
1313
Assert-NotNull $installerEvents
1414
}
1515

16-
# If this test fails with the cryptic error:
17-
#
18-
# Exception calling "NewProject" with "5" argument(s): "The method or operation is not implemented."
19-
#
20-
# ...it is because the specific Windows 10 SDK build indicated by the <TargetPlatformVersion /> element in the test's
21-
# project file (test\EndToEnd\ProjectTemplates\UwpClassLibraryProjectJson.zip\ClassLibrary6.csproj) is not installed.
22-
function Test-MigrateVanillaUwpProjectJsonToPackageReference {
23-
param(
24-
$context
25-
)
26-
27-
# Arrange
28-
$p = New-UwpClassLibraryProjectJson UwpClassLibrary1
29-
$cm = Get-VsComponentModel
30-
$projectDir = Get-ProjectDir $p
31-
$result = [API.Test.InternalAPITestHook]::MigrateJsonProject($p.FullName)
32-
Start-Sleep -Seconds 3
33-
# Assert
34-
35-
# Check if runtimes were migrated correctly
36-
$expectRuntimeIds = 'win10-arm;win10-arm-aot;win10-x86;win10-x86-aot;win10-x64;win10-x64-aot'
37-
Assert-True($result.IsSuccess)
38-
$actualRuntimes = Get-MsBuildPropertyValue $p 'RuntimeIdentifiers'
39-
Assert-AreEqual $expectRuntimeIds $actualRuntimes
40-
41-
# Check if project.json file was deleted
42-
Assert-True !(Test-Path (Join-Path $projectDir project.json))
43-
44-
# Check if backup was created
45-
$backupProjectJsonPath = [System.IO.Path]::Combine($projectDir, "Backup", "project.json")
46-
$backupCsprojPath = [System.IO.Path]::Combine($projectDir, "Backup", "UwpClassLibrary1.csproj")
47-
Write-Host "Project json backup path: $backupProjectJsonPath"
48-
Write-Host "Csproj backup path: $backupCsprojPath"
49-
Assert-True (Test-Path $backupProjectJsonPath)
50-
Assert-True (Test-Path $backupCsprojPath)
51-
52-
# Check if package reference was added correctly
53-
$packageRefs = @(Get-MsBuildItems $p 'PackageReference')
54-
Assert-AreEqual 1 $packageRefs.Count
55-
Assert-AreEqual $packageRefs[0].GetMetadataValue("Identity") 'Microsoft.NETCore.UniversalWindowsPlatform'
56-
Assert-AreEqual $packageRefs[0].GetMetadataValue("Version") '5.2.2'
57-
}
58-
5916
function Test-VsPackageInstallerServices {
6017
param(
6118
$context

0 commit comments

Comments
 (0)