@@ -11,7 +11,7 @@ public class DotnetNewTestTemplatesTests : BaseIntegrationTest
11
11
12
12
private static readonly ImmutableArray < string > SupportedTargetFrameworks =
13
13
[
14
- "net10.0" ,
14
+ ToolsetInfo . CurrentTargetFramework
15
15
] ;
16
16
17
17
private static readonly ( string ProjectTemplateName , string ItemTemplateName , string [ ] Languages , bool SupportsTestingPlatform ) [ ] AvailableItemTemplates =
@@ -50,13 +50,16 @@ public void WriteLine(string format, params object[] args) { }
50
50
51
51
static DotnetNewTestTemplatesTests ( )
52
52
{
53
+ // This is the live location of the build
53
54
string templatePackagePath = Path . Combine (
54
55
RepoTemplatePackages ,
55
- "Microsoft.DotNet.Common.ProjectTemplates.10.0 " ,
56
+ $ "Microsoft.DotNet.Common.ProjectTemplates.{ ToolsetInfo . CurrentTargetFrameworkVersion } ",
56
57
"content" ) ;
57
58
58
59
var dummyLog = new NullTestOutputHelper ( ) ;
59
60
61
+ // Here we uninstall first, because we want to make sure we clean up before the installation
62
+ // i.e we want to make sure our installation is done
60
63
new DotnetNewCommand ( dummyLog , "uninstall" , templatePackagePath )
61
64
. WithCustomHive ( CreateTemporaryFolder ( folderName : "Home" ) )
62
65
. WithWorkingDirectory ( CreateTemporaryFolder ( ) )
@@ -66,7 +69,8 @@ static DotnetNewTestTemplatesTests()
66
69
. WithCustomHive ( CreateTemporaryFolder ( folderName : "Home" ) )
67
70
. WithWorkingDirectory ( CreateTemporaryFolder ( ) )
68
71
. Execute ( )
69
- . Should ( ) . ExitWith ( 0 ) ;
72
+ . Should ( )
73
+ . Pass ( ) ;
70
74
}
71
75
72
76
[ Theory ]
@@ -80,19 +84,21 @@ public void ItemTemplate_CanBeInstalledAndTestArePassing(string targetFramework,
80
84
// Create new test project: dotnet new <projectTemplate> -n <testProjectName> -f <targetFramework> -lang <language>
81
85
string args = $ "{ projectTemplate } -n { testProjectName } -f { targetFramework } -lang { language } -o { outputDirectory } ";
82
86
new DotnetNewCommand ( _log , args )
83
- . WithCustomHive ( outputDirectory ) . WithRawArguments ( )
84
- . WithWorkingDirectory ( workingDirectory )
85
- . Execute ( )
86
- . Should ( ) . ExitWith ( 0 ) ;
87
+ . WithCustomHive ( outputDirectory ) . WithRawArguments ( )
88
+ . WithWorkingDirectory ( workingDirectory )
89
+ . Execute ( )
90
+ . Should ( )
91
+ . Pass ( ) ;
87
92
88
93
var itemName = "test" ;
89
94
90
- // Add test item to test project: dotnet new <itemTemplate> -n <test> -lang <language> -o <testProjectName >
95
+ // Add test item to test project: dotnet new <itemTemplate> -n <test> -lang <language> -o <outputDirectory >
91
96
new DotnetNewCommand ( _log , $ "{ itemTemplate } -n { itemName } -lang { language } -o { outputDirectory } ")
92
97
. WithCustomHive ( outputDirectory ) . WithRawArguments ( )
93
98
. WithWorkingDirectory ( workingDirectory )
94
99
. Execute ( )
95
- . Should ( ) . ExitWith ( 0 ) ;
100
+ . Should ( )
101
+ . Pass ( ) ;
96
102
97
103
if ( language == Languages . FSharp )
98
104
{
@@ -106,9 +112,11 @@ public void ItemTemplate_CanBeInstalledAndTestArePassing(string targetFramework,
106
112
. WithWorkingDirectory ( outputDirectory )
107
113
. Execute ( outputDirectory ) ;
108
114
109
- result . Should ( ) . ExitWith ( 0 ) ;
115
+ result . Should ( ) . Pass ( ) ;
110
116
111
117
result . StdOut . Should ( ) . Contain ( "Passed!" ) ;
118
+ // We created another test class (which will contain 1 test), and we already have 1 test when we created the test project.
119
+ // Therefore, in total we would have 2.
112
120
result . StdOut . Should ( ) . MatchRegex ( @"Passed:\s*2" ) ;
113
121
114
122
Directory . Delete ( outputDirectory , true ) ;
@@ -126,18 +134,19 @@ public void ProjectTemplate_CanBeInstalledAndTestsArePassing(string targetFramew
126
134
// Create new test project: dotnet new <projectTemplate> -n <testProjectName> -f <targetFramework> -lang <language>
127
135
string args = $ "{ projectTemplate } -n { testProjectName } -f { targetFramework } -lang { language } -o { outputDirectory } ";
128
136
new DotnetNewCommand ( _log , args )
129
- . WithCustomHive ( outputDirectory ) . WithRawArguments ( )
130
- . WithWorkingDirectory ( workingDirectory )
131
- . Execute ( )
132
- . Should ( ) . ExitWith ( 0 ) ;
137
+ . WithCustomHive ( outputDirectory ) . WithRawArguments ( )
138
+ . WithWorkingDirectory ( workingDirectory )
139
+ . Execute ( )
140
+ . Should ( )
141
+ . Pass ( ) ;
133
142
134
143
if ( runDotnetTest )
135
144
6D4E
{
136
145
var result = new DotnetTestCommand ( _log , false )
137
146
. WithWorkingDirectory ( outputDirectory )
138
147
. Execute ( outputDirectory ) ;
139
148
140
- result . Should ( ) . ExitWith ( 0 ) ;
149
+ result . Should ( ) . Pass ( ) ;
141
150
142
151
result . StdOut . Should ( ) . Contain ( "Passed!" ) ;
143
152
result . StdOut . Should ( ) . MatchRegex ( @"Passed:\s*1" ) ;
@@ -164,18 +173,19 @@ public void MSTestAndPlaywrightProjectTemplate_WithCoverageToolAndTestRunner_Can
164
173
// Create new test project: dotnet new <projectTemplate> -n <testProjectName> -f <targetFramework> -lang <language> --coverage-tool <coverageTool> --test-runner <testRunner>
165
174
string args = $ "{ projectTemplate } -n { testProjectName } -f { targetFramework } -lang { language } -o { outputDirectory } --coverage-tool { coverageTool } --test-runner { testRunner } ";
166
175
new DotnetNewCommand ( _log , args )
167
- . WithCustomHive ( outputDirectory ) . WithRawArguments ( )
168
- . WithWorkingDirectory ( workingDirectory )
169
- . Execute ( )
170
- . Should ( ) . ExitWith ( 0 ) ;
176
+ . WithCustomHive ( outputDirectory ) . WithRawArguments ( )
177
+ . WithWorkingDirectory ( workingDirectory )
178
+ . Execute ( )
179
+ . Should ( )
180
+ . Pass ( ) ;
171
181
172
182
if ( runDotnetTest )
173
183
{
174
184
var result = new DotnetTestCommand ( _log , false )
175
185
. WithWorkingDirectory ( outputDirectory )
176
186
. Execute ( outputDirectory ) ;
177
187
178
- result . Should ( ) . ExitWith ( 0 ) ;
188
+ result . Should ( ) . Pass ( ) ;
179
189
180
190
result . StdOut . Should ( ) . Contain ( "Passed!" ) ;
181
191
result . StdOut . Should ( ) . MatchRegex ( @"Passed:\s*1" ) ;
0 commit comments