@@ -80,18 +80,6 @@ public void BuildWithGlobalProperties()
8080 buildOutputWithGlobalProperties . MessageEvents . High . ShouldHaveSingleItem ( buildOutputWithGlobalProperties . GetConsoleLog ( ) ) . Message . ShouldBe ( "Value = D7BBABDFB2D142D3A75E0C1A33E33780" , buildOutputWithGlobalProperties . GetConsoleLog ( ) ) ;
8181 }
8282
83- [ Fact ]
84- public void ProjectWithNoPathBuildThrowsInvalidOperationException ( )
85- {
86- InvalidOperationException exception = Should . Throw < InvalidOperationException > ( ( ) =>
87- {
88- ProjectCreator . Templates . LogsMessage ( "6E83EF78-959F-45A2-9FE3-08BAD99C0F92" )
89- . TryBuild ( out bool _ ) ;
90- } ) ;
91-
92- exception . Message . ShouldBe ( "Project has not been given a path to save to." ) ;
93- }
94-
9583 [ Fact ]
9684 public void CanBuildLotsOfProjects ( )
9785 {
@@ -233,6 +221,77 @@ public void ProjectCollectionLoggersWorkWithRestore()
233221 fileLogContents . ShouldContain ( "B7F9A257198D4A44A06BB6146AB27440" , Case . Sensitive , fileLogContents ) ;
234222 }
235223
224+ [ Fact ]
225+ public void ProjectWithNoPathBuildThrowsInvalidOperationException ( )
226+ {
227+ InvalidOperationException exception = Should . Throw < InvalidOperationException > ( ( ) =>
228+ {
229+ ProjectCreator . Templates . LogsMessage ( "6E83EF78-959F-45A2-9FE3-08BAD99C0F92" )
230+ . TryBuild ( out bool _ ) ;
231+ } ) ;
232+
233+ exception . Message . ShouldBe ( "Project has not been given a path to save to." ) ;
234+ }
235+
236+ [ Fact ]
237+ public void RestoreAndBuildUseDifferentGlobalPropertiesWhenGlobalPropertiesSpecified ( )
238+ {
239+ Dictionary < string , string > globalProperties = new Dictionary < string , string >
240+ {
241+ [ "Something" ] = bool . TrueString ,
242+ } ;
243+
244+ ProjectCreator . Create (
245+ path : GetTempFileName ( ".csproj" ) )
246+ . Target ( "Restore" )
247+ . TaskMessage ( "Restore $(ExcludeRestorePackageImports)" , MessageImportance . High )
248+ . TaskMessage ( "Restore Something $(Something)" , MessageImportance . High )
249+ . Target ( "Build" )
250+ . TaskMessage ( "Build $(ExcludeRestorePackageImports)" , MessageImportance . High )
251+ . TaskMessage ( "Build Something $(Something)" , MessageImportance . High )
252+ . Save ( )
253+ . TryBuild ( restore : true , "Build" , globalProperties , out bool result , out BuildOutput buildOutput ) ;
254+
255+ result . ShouldBeTrue ( buildOutput . GetConsoleLog ( ) ) ;
256+
257+ buildOutput . MessageEvents . High . ShouldContain ( i => i . Message == "Restore true" , buildOutput . GetConsoleLog ( ) ) ;
258+ buildOutput . MessageEvents . High . ShouldContain ( i => i . Message == "Restore Something True" , buildOutput . GetConsoleLog ( ) ) ;
259+
260+ buildOutput . MessageEvents . High . ShouldNotContain ( i => i . Message == "Build true" , buildOutput . GetConsoleLog ( ) ) ;
261+ buildOutput . MessageEvents . High . ShouldContain ( i => i . Message == "Build Something True" , buildOutput . GetConsoleLog ( ) ) ;
262+ }
263+
264+ [ Fact ]
265+ public void RestoreAndBuildUseDifferentGlobalPropertiesWhenProjectCollectionSpecified ( )
266+ {
267+ Dictionary < string , string > globalProperties = new Dictionary < string , string >
268+ {
269+ [ "Something" ] = bool . TrueString ,
270+ } ;
271+
272+ using ProjectCollection projectCollection = new ProjectCollection ( globalProperties ) ;
273+
274+ ProjectCreator . Create (
275+ path : GetTempFileName ( ".csproj" ) ,
276+ projectCollection : projectCollection )
277+ . Target ( "Restore" )
278+ . TaskMessage ( "Restore $(ExcludeRestorePackageImports)" , MessageImportance . High )
279+ . TaskMessage ( "Restore Something $(Something)" , MessageImportance . High )
280+ . Target ( "Build" )
281+ . TaskMessage ( "Build $(ExcludeRestorePackageImports)" , MessageImportance . High )
282+ . TaskMessage ( "Build Something $(Something)" , MessageImportance . High )
283+ . Save ( )
284+ . TryBuild ( restore : true , "Build" , globalProperties , out bool result , out BuildOutput buildOutput ) ;
285+
286+ result . ShouldBeTrue ( buildOutput . GetConsoleLog ( ) ) ;
287+
288+ buildOutput . MessageEvents . High . ShouldContain ( i => i . Message == "Restore true" , buildOutput . GetConsoleLog ( ) ) ;
289+ buildOutput . MessageEvents . High . ShouldContain ( i => i . Message == "Restore Something True" , buildOutput . GetConsoleLog ( ) ) ;
290+
291+ buildOutput . MessageEvents . High . ShouldNotContain ( i => i . Message == "Build true" , buildOutput . GetConsoleLog ( ) ) ;
292+ buildOutput . MessageEvents . High . ShouldContain ( i => i . Message == "Build Something True" , buildOutput . GetConsoleLog ( ) ) ;
293+ }
294+
236295 [ Fact ]
237296 public void RestoreTargetCanBeRun ( )
238297 {
0 commit comments