1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
- using Microsoft . DotNet . TestFramework ;
4
+ //using Microsoft.DotNet.TestFramework;
5
+ using EndToEnd . Tests . Utilities ;
5
6
using NuGet . ProjectModel ;
6
7
using NuGet . Versioning ;
7
- using RestoreCommand = Microsoft . DotNet . Tools . Test . Utilities . RestoreCommand ;
8
- using NewCommandShim = Microsoft . DotNet . Tools . Test . Utilities . NewCommandShim ;
9
- using TestBase = Microsoft . DotNet . Tools . Test . Utilities . TestBase ;
10
- using static Microsoft . DotNet . Tools . Test . Utilities . TestCommandExtensions ;
8
+ // using RestoreCommand = Microsoft.DotNet.Tools.Test.Utilities.RestoreCommand;
9
+ // using NewCommandShim = Microsoft.DotNet.Tools.Test.Utilities.NewCommandShim;
10
+ // using TestBase = Microsoft.DotNet.Tools.Test.Utilities.TestBase;
11
+ // using static Microsoft.DotNet.Tools.Test.Utilities.TestCommandExtensions;
11
12
12
- namespace EndToEnd
13
+ namespace EndToEnd . Tests
13
14
{
14
- public partial class GivenSelfContainedAppsRollForward : TestBase
15
+ public partial class GivenSelfContainedAppsRollForward ( ITestOutputHelper log ) : SdkTest ( log )
15
16
{
17
+ public const string NETCorePackageName = "Microsoft.NETCore.App" ;
18
+ public const string AspNetCoreAppPackageName = "Microsoft.AspNetCore.App" ;
19
+ public const string AspNetCoreAllPackageName = "Microsoft.AspNetCore.All" ;
20
+
21
+ [ Theory ]
22
+ [ ClassData ( typeof ( SupportedNetCoreAppVersions ) ) ]
23
+ public void ItRollsForwardToTheLatestNetCoreVersion ( string minorVersion )
24
+ {
25
+ ItRollsForwardToTheLatestVersion ( NETCorePackageName , minorVersion ) ;
26
+ }
27
+
28
+ [ Theory ]
29
+ [ ClassData ( typeof ( SupportedAspNetCoreVersions ) ) ]
30
+ public void ItRollsForwardToTheLatestAspNetCoreAppVersion ( string minorVersion )
31
+ {
32
+ ItRollsForwardToTheLatestVersion ( AspNetCoreAppPackageName , minorVersion ) ;
33
+ }
34
+
35
+ [ Theory ]
36
+ [ ClassData ( typeof ( SupportedAspNetCoreVersions ) ) ]
37
+ public void ItRollsForwardToTheLatestAspNetCoreAllVersion ( string minorVersion )
38
+ {
39
+ ItRollsForwardToTheLatestVersion ( AspNetCoreAllPackageName , minorVersion ) ;
40
+ }
41
+
16
42
internal void ItRollsForwardToTheLatestVersion ( string packageName , string minorVersion )
17
43
{
18
44
var testProjectCreator = new TestProjectCreator ( )
@@ -23,16 +49,13 @@ internal void ItRollsForwardToTheLatestVersion(string packageName, string minorV
23
49
RuntimeIdentifier = RuntimeInformation . RuntimeIdentifier
24
50
} ;
25
51
26
- var testInstance = testProjectCreator . Create ( ) ;
27
-
28
- string projectDirectory = testInstance . Root . FullName ;
52
+ var testInstance = testProjectCreator . Create ( _testAssetsManager ) ;
29
53
30
54
// Get the version rolled forward to
31
- new RestoreCommand ( )
32
- . WithWorkingDirectory ( projectDirectory )
33
- . Execute ( ) . Should ( ) . Pass ( ) ;
55
+ new RestoreCommand ( testInstance )
56
+ . Execute ( ) . Should ( ) . Pass ( ) ;
34
57
35
- string assetsFilePath = Path . Combine ( projectDirectory , "obj" , "project.assets.json" ) ;
58
+ string assetsFilePath = Path . Combine ( testInstance . TestRoot , "obj" , "project.assets.json" ) ;
36
59
var assetsFile = new LockFileFormat ( ) . Read ( assetsFilePath ) ;
37
60
38
61
var rolledForwardVersion = GetPackageVersion ( assetsFile , packageName ) ;
@@ -49,14 +72,13 @@ internal void ItRollsForwardToTheLatestVersion(string packageName, string minorV
49
72
50
73
testProjectCreator . Identifier = "floating" ;
51
74
52
- var floatingProjectInstance = testProjectCreator . Create ( ) ;
75
+ var floatingProjectInstance = testProjectCreator . Create ( _testAssetsManager ) ;
53
76
54
- var floatingProjectPath = Path . Combine ( floatingProjectInstance . Root . FullName , "TestAppSimple.csproj" ) ;
77
+ var floatingProjectPath = Path . Combine ( floatingProjectInstance . TestRoot , "TestAppSimple.csproj" ) ;
55
78
56
79
var floatingProject = XDocument . Load ( floatingProjectPath ) ;
57
80
var ns = floatingProject . Root . Name . Namespace ;
58
81
59
-
60
82
if ( packageName == TestProjectCreator . NETCorePackageName )
61
83
{
62
84
// Float the RuntimeFrameworkVersion to get the latest version of the runtime available from feeds
@@ -73,11 +95,10 @@ internal void ItRollsForwardToTheLatestVersion(string packageName, string minorV
73
95
74
96
floatingProject . Save ( floatingProjectPath ) ;
75
97
76
- new RestoreCommand ( )
77
- . WithWorkingDirectory ( floatingProjectInstance . Root . FullName )
78
- . Execute ( ) . Should ( ) . Pass ( ) ;
98
+ new RestoreCommand ( floatingProjectInstance )
99
+ . Execute ( ) . Should ( ) . Pass ( ) ;
79
100
80
- string floatingAssetsFilePath = Path . Combine ( floatingProjectInstance . Root . FullName , "obj" , "project.assets.json" ) ;
101
+ string floatingAssetsFilePath = Path . Combine ( floatingProjectInstance . TestRoot , "obj" , "project.assets.json" ) ;
81
102
82
103
var floatedAssetsFile = new LockFileFormat ( ) . Read ( floatingAssetsFilePath ) ;
83
104
@@ -98,12 +119,13 @@ private static NuGetVersion GetPackageVersion(LockFile lockFile, string packageN
98
119
public void WeCoverLatestNetCoreAppRollForward ( )
99
120
{
100
121
// Run "dotnet new console", get TargetFramework property, and make sure it's covered in SupportedNetCoreAppVersions
101
- var directory = TestAssets . CreateTestDirectory ( ) ;
102
- string projectDirectory = directory . FullName ;
122
+ var directory = _testAssetsManager . CreateTestDirectory ( ) ;
123
+ string projectDirectory = directory . Path ;
103
124
104
- new NewCommandShim ( )
125
+ new DotnetNewCommand ( Log , "web" , "--no-restore" )
126
+ . WithVirtualHive ( )
105
127
. WithWorkingDirectory ( projectDirectory )
106
- . Execute ( "console --no-restore" ) . Should ( ) . Pass ( ) ;
128
+ . Execute ( ) . Should ( ) . Pass ( ) ;
107
129
108
130
string projectPath = Path . Combine ( projectDirectory , Path . GetFileName ( projectDirectory ) + ".csproj" ) ;
109
131
@@ -122,14 +144,15 @@ public void WeCoverLatestNetCoreAppRollForward()
122
144
[ Fact ]
123
145
public void WeCoverLatestAspNetCoreAppRollForward ( )
124
146
{
125
- var directory = TestAssets . CreateTestDirectory ( ) ;
126
- string projectDirectory = directory . FullName ;
147
+ var directory = _testAssetsManager . CreateTestDirectory ( ) ;
148
+ string projectDirectory = directory . Path ;
127
149
128
150
// Run "dotnet new web", get TargetFramework property, and make sure it's covered in SupportedAspNetCoreAppVersions
129
151
130
- new NewCommandShim ( )
152
+ new DotnetNewCommand ( Log , "web" , "--no-restore" )
153
+ . WithVirtualHive ( )
131
154
. WithWorkingDirectory ( projectDirectory )
132
- . Execute ( "web --no-restore" ) . Should ( ) . Pass ( ) ;
155
+ . Execute ( ) . Should ( ) . Pass ( ) ;
133
156
134
157
string projectPath = Path . Combine ( projectDirectory , Path . GetFileName ( projectDirectory ) + ".csproj" ) ;
135
158
@@ -142,7 +165,7 @@ public void WeCoverLatestAspNetCoreAppRollForward()
142
165
143
166
TargetFrameworkHelper . GetNetAppTargetFrameworks ( SupportedAspNetCoreVersions . Versions )
144
167
. Should ( ) . Contain ( targetFramework , $ "the { nameof ( SupportedAspNetCoreVersions ) } should include the default version " +
145
- "of Microsoft.AspNetCore.App used by the templates created by \" dotnet new web\" " ) ;
168
+ "of Microsoft.AspNetCore.App used by the templates created by \" dotnet new web\" " ) ;
146
169
}
147
170
}
148
171
}
0 commit comments