@@ -26,19 +26,19 @@ public void Dispose()
26
26
}
27
27
28
28
[ Theory ]
29
- [ CombinatorialData ]
30
- public async Task RunTestApp_NoUsingAndNoAssembly ( bool singleFile )
29
+ [ ClassData ( typeof ( PublishModeTheoryData ) ) ]
30
+ public async Task RunTestApp_NoUsingAndNoAssembly ( PublishMode publishMode )
31
31
{
32
- var ( isSingleFile , stdOut , stdErr ) = await RunTestAppAsync ( singleFile ) ;
32
+ var ( isSingleFile , stdOut , stdErr ) = await RunTestAppAsync ( publishMode ) ;
33
33
stdOut . Should ( ) . Be ( isSingleFile ? "Expected exception" : "(Main thread) [Information] Expected success" ) ;
34
34
stdErr . Should ( ) . BeEmpty ( ) ;
35
35
}
36
36
37
37
[ Theory ]
38
- [ CombinatorialData ]
39
- public async Task RunTestApp_UsingConsole ( bool singleFile )
38
+ [ ClassData ( typeof ( PublishModeTheoryData ) ) ]
39
+ public async Task RunTestApp_UsingConsole ( PublishMode publishMode )
40
40
{
41
- var ( isSingleFile , stdOut , stdErr ) = await RunTestAppAsync ( singleFile , "--using-console" ) ;
41
+ var ( isSingleFile , stdOut , stdErr ) = await RunTestAppAsync ( publishMode , "--using-console" ) ;
42
42
stdOut . Should ( ) . Be ( isSingleFile ? "() [Information] Expected success" : "(Main thread) [Information] Expected success" ) ;
43
43
if ( isSingleFile )
44
44
stdErr . Should ( ) . Contain ( "Unable to find a method called WithThreadName" ) ;
@@ -47,10 +47,10 @@ public async Task RunTestApp_UsingConsole(bool singleFile)
47
47
}
48
48
49
49
[ Theory ]
50
- [ CombinatorialData ]
51
- public async Task RunTestApp_UsingThread ( bool singleFile )
50
+ [ ClassData ( typeof ( PublishModeTheoryData ) ) ]
51
+ public async Task RunTestApp_UsingThread ( PublishMode publishMode )
52
52
{
53
- var ( isSingleFile , stdOut , stdErr ) = await RunTestAppAsync ( singleFile , "--using-thread" ) ;
53
+ var ( isSingleFile , stdOut , stdErr ) = await RunTestAppAsync ( publishMode , "--using-thread" ) ;
54
54
stdOut . Should ( ) . Be ( isSingleFile ? "" : "(Main thread) [Information] Expected success" ) ;
55
55
if ( isSingleFile )
56
56
stdErr . Should ( ) . Contain ( "Unable to find a method called Console" ) ;
@@ -59,48 +59,48 @@ public async Task RunTestApp_UsingThread(bool singleFile)
59
59
}
60
60
61
61
[ Theory ]
62
- [ CombinatorialData ]
63
- public async Task RunTestApp_AssemblyThread ( bool singleFile )
62
+ [ ClassData ( typeof ( PublishModeTheoryData ) ) ]
63
+ public async Task RunTestApp_AssemblyThread ( PublishMode publishMode )
64
64
{
65
- var ( _, stdOut , stdErr ) = await RunTestAppAsync ( singleFile , "--assembly-thread" ) ;
65
+ var ( _, stdOut , stdErr ) = await RunTestAppAsync ( publishMode , "--assembly-thread" ) ;
66
66
stdOut . Should ( ) . BeEmpty ( ) ;
67
67
stdErr . Should ( ) . Contain ( "Unable to find a method called Console" ) ;
68
68
}
69
69
70
70
[ Theory ]
71
- [ CombinatorialData ]
72
- public async Task RunTestApp_AssemblyConsole ( bool singleFile )
71
+ [ ClassData ( typeof ( PublishModeTheoryData ) ) ]
72
+ public async Task RunTestApp_AssemblyConsole ( PublishMode publishMode )
73
73
{
74
- var ( _, stdOut , stdErr ) = await RunTestAppAsync ( singleFile , "--assembly-console" ) ;
74
+ var ( _, stdOut , stdErr ) = await RunTestAppAsync ( publishMode , "--assembly-console" ) ;
75
75
stdOut . Should ( ) . Be ( "() [Information] Expected success" ) ;
76
76
stdErr . Should ( ) . Contain ( "Unable to find a method called WithThreadName" ) ;
77
77
}
78
78
79
79
[ Theory ]
80
- [ CombinatorialData ]
81
- public async Task RunTestApp_ConsoleAndThread ( bool singleFile , [ CombinatorialValues ( "using" , "assembly" ) ] string strategy )
80
+ [ ClassData ( typeof ( PublishModeAndStrategyTheoryData ) ) ]
81
+ public async Task RunTestApp_ConsoleAndThread ( PublishMode publishMode , string strategy )
82
82
{
83
- var ( _, stdOut , stdErr ) = await RunTestAppAsync ( singleFile , $ "--{ strategy } -console", $ "--{ strategy } -thread") ;
83
+ var ( _, stdOut , stdErr ) = await RunTestAppAsync ( publishMode , $ "--{ strategy } -console", $ "--{ strategy } -thread") ;
84
84
stdOut . Should ( ) . Be ( "(Main thread) [Information] Expected success" ) ;
85
85
stdErr . Should ( ) . BeEmpty ( ) ;
86
86
}
87
87
88
- async Task < ( bool IsSingleFile , string StdOut , string StdErr ) > RunTestAppAsync ( bool singleFile , params string [ ] args )
88
+ async Task < ( bool IsSingleFile , string StdOut , string StdErr ) > RunTestAppAsync ( PublishMode publishMode , params string [ ] args )
89
89
{
90
90
// Determine whether the app is a _true_ single file, i.e. not a .NET Core 3.x version which
91
91
// [extracts bundled files to disk][1] and thus can find dlls.
92
92
// [1]: https://github.com/dotnet/designs/blob/main/accepted/2020/single-file/extract.md
93
- var ( isSingleFile , _) = await RunTestAppInternalAsync ( singleFile , "is-single-file" ) ;
94
- var ( stdOut , stdErr ) = await RunTestAppInternalAsync ( singleFile , args ) ;
93
+ var ( isSingleFile , _) = await RunTestAppInternalAsync ( publishMode , "is-single-file" ) ;
94
+ var ( stdOut , stdErr ) = await RunTestAppInternalAsync ( publishMode , args ) ;
95
95
return ( bool . Parse ( isSingleFile ) , stdOut , stdErr ) ;
96
96
}
97
97
98
- async Task < ( string StdOut , string StdErr ) > RunTestAppInternalAsync ( bool singleExe , params string [ ] args )
98
+ async Task < ( string StdOut , string StdErr ) > RunTestAppInternalAsync ( PublishMode publishMode , params string [ ] args )
99
99
{
100
100
var stdOutBuilder = new StringBuilder ( ) ;
101
101
var stdErrBuilder = new StringBuilder ( ) ;
102
102
103
- var command = Cli . Wrap ( singleExe ? _testApp . SingleFileExe . FullName : _testApp . StandardExe . FullName )
103
+ var command = Cli . Wrap ( _testApp . GetExecutablePath ( publishMode ) )
104
104
. WithArguments ( args )
105
105
. WithValidation ( CommandResultValidation . None )
106
106
. WithStandardOutputPipe ( PipeTarget . ToStringBuilder ( stdOutBuilder ) )
@@ -122,9 +122,34 @@ public async Task RunTestApp_ConsoleAndThread(bool singleFile, [CombinatorialVal
122
122
123
123
if ( result . ExitCode != 0 )
124
124
{
125
- throw new Exception ( $ "An unexpected exception has occurred while running { command } . { stdErr } ". Trim ( ) ) ;
125
+ throw new Exception ( $ "An unexpected exception has occurred while running { command } { Environment . NewLine } { stdErr } ". Trim ( ) ) ;
126
126
}
127
127
128
128
return ( stdOut , stdErr ) ;
129
129
}
130
+
131
+ class PublishModeTheoryData : TheoryData < PublishMode >
132
+ {
133
+ public PublishModeTheoryData ( )
134
+ {
135
+ foreach ( var publishMode in PublishModeExtensions . GetPublishModes ( ) )
136
+ {
137
+ Add ( publishMode ) ;
138
+ }
139
+ }
140
+ }
141
+
142
+ class PublishModeAndStrategyTheoryData : TheoryData < PublishMode , string >
143
+ {
144
+ public PublishModeAndStrategyTheoryData ( )
145
+ {
146
+ foreach ( var publishMode in PublishModeExtensions . GetPublishModes ( ) )
147
+ {
148
+ foreach ( var strategy in new [ ] { "using" , "assembly" } )
149
+ {
150
+ Add ( publishMode , strategy ) ;
151
+ }
152
+ }
153
+ }
154
+ }
130
155
}
0 commit comments