@@ -21,22 +21,23 @@ public HostVersionCompatibility(SharedTestState fixture)
2121 [ Fact ]
2222 public void LatestHost_OldRuntime_BackwardsCompatible_60 ( )
2323 {
24- LatestHost_OldRuntime_BackwardsCompatible ( sharedTestState . Fixture60 ) ;
24+ LatestHost_OldRuntime_BackwardsCompatible ( sharedTestState . App60 ) ;
2525 }
2626
27- private void LatestHost_OldRuntime_BackwardsCompatible ( TestProjectFixture previousVersionFixture )
27+ private void LatestHost_OldRuntime_BackwardsCompatible ( TestApp previousVersionApp )
2828 {
29- TestProjectFixture fixture = previousVersionFixture . Copy ( ) ;
30- string appExe = fixture . TestProject . AppExe ;
29+ TestApp app = previousVersionApp . Copy ( ) ;
30+ string appExe = app . AppExe ;
3131
32- Assert . NotEqual ( fixture . Framework , RepoDirectoriesProvider . Default . Tfm ) ;
33- Assert . NotEqual ( fixture . RepoDirProvider . MicrosoftNETCoreAppVersion , RepoDirectoriesProvider . Default . MicrosoftNETCoreAppVersion ) ;
32+ RuntimeConfig appConfig = RuntimeConfig . FromFile ( app . RuntimeConfigJson ) ;
33+ Assert . NotEqual ( appConfig . Tfm , RepoDirectoriesProvider . Default . Tfm ) ;
34+ Assert . NotEqual ( appConfig . GetIncludedFramework ( Constants . MicrosoftNETCoreApp ) . Version , RepoDirectoriesProvider . Default . MicrosoftNETCoreAppVersion ) ;
3435
3536 // Use the newer apphost
3637 // This emulates the case when:
3738 // 1) Newer runtime installed
3839 // 2) Newer runtime uninstalled (installer preserves newer apphost)
39- fixture . TestProject . BuiltApp . CreateAppHost ( ) ;
40+ app . CreateAppHost ( ) ;
4041 Command . Create ( appExe )
4142 . EnableTracingAndCaptureOutputs ( )
4243 . Execute ( )
@@ -48,7 +49,7 @@ private void LatestHost_OldRuntime_BackwardsCompatible(TestProjectFixture previo
4849 // This emulates the case when:
4950 // 1) Newer runtime installed
5051 // 2) A roll-forward to the newer runtime did not occur
51- File . Copy ( Binaries . HostFxr . FilePath , fixture . TestProject . HostFxrDll , true ) ;
52+ File . Copy ( Binaries . HostFxr . FilePath , app . HostFxrDll , true ) ;
5253 Command . Create ( appExe )
5354 . EnableTracingAndCaptureOutputs ( )
5455 . Execute ( )
@@ -60,28 +61,30 @@ private void LatestHost_OldRuntime_BackwardsCompatible(TestProjectFixture previo
6061 [ Fact ]
6162 public void OldHost_LatestRuntime_ForwardCompatible_60 ( )
6263 {
63- OldHost_LatestRuntime_ForwardCompatible ( sharedTestState . Fixture60 ) ;
64+ OldHost_LatestRuntime_ForwardCompatible ( sharedTestState . App60 ) ;
6465 }
6566
66- private void OldHost_LatestRuntime_ForwardCompatible ( TestProjectFixture previousVersionFixture )
67+ private void OldHost_LatestRuntime_ForwardCompatible ( TestApp previousVersionApp )
6768 {
6869 TestApp app = sharedTestState . AppLatest . Copy ( ) ;
6970 string appExe = app . AppExe ;
7071
71- Assert . NotEqual ( RepoDirectoriesProvider . Default . Tfm , previousVersionFixture . Framework ) ;
72- Assert . NotEqual ( RepoDirectoriesProvider . Default . MicrosoftNETCoreAppVersion , previousVersionFixture . RepoDirProvider . MicrosoftNETCoreAppVersion ) ;
72+ RuntimeConfig previousAppConfig = RuntimeConfig . FromFile ( previousVersionApp . RuntimeConfigJson ) ;
73+ string previousVersion = previousAppConfig . GetIncludedFramework ( Constants . MicrosoftNETCoreApp ) . Version ;
74+ Assert . NotEqual ( RepoDirectoriesProvider . Default . Tfm , previousAppConfig . Tfm ) ;
75+ Assert . NotEqual ( RepoDirectoriesProvider . Default . MicrosoftNETCoreAppVersion , previousVersion ) ;
7376
7477 // Use the older apphost
7578 // This emulates the case when:
7679 // 1) Newer runtime installed
7780 // 2) App rolls forward to newer runtime
78- File . Copy ( previousVersionFixture . TestProject . AppExe , appExe , true ) ;
81+ File . Copy ( previousVersionApp . AppExe , appExe , true ) ;
7982 Command . Create ( appExe )
8083 . EnableTracingAndCaptureOutputs ( )
8184 . Execute ( )
8285 . Should ( ) . Pass ( )
8386 . And . HaveStdOutContaining ( "Hello World" )
84- . And . HaveStdErrContaining ( $ "--- Invoked apphost [version: { previousVersionFixture . RepoDirProvider . MicrosoftNETCoreAppVersion } ") ;
87+ . And . HaveStdErrContaining ( $ "--- Invoked apphost [version: { previousVersion } ") ;
8588
8689 // Use the older apphost and hostfxr
8790 // This emulates the case when:
@@ -90,53 +93,36 @@ private void OldHost_LatestRuntime_ForwardCompatible(TestProjectFixture previous
9093 // Note that we don't have multi-level on hostfxr so we will always find the older\one-off hostfxr
9194 if ( OperatingSystem . IsWindows ( ) )
9295 {
93- File . Copy ( previousVersionFixture . TestProject . HostFxrDll , app . HostFxrDll , true ) ;
96+ File . Copy ( previousVersionApp . HostFxrDll , app . HostFxrDll , true ) ;
9497 Command . Create ( appExe )
9598 . EnableTracingAndCaptureOutputs ( )
9699 . Execute ( )
97100 . Should ( ) . Pass ( )
98101 . And . HaveStdOutContaining ( "Hello World" )
99- . And . HaveStdErrContaining ( $ "--- Invoked apphost [version: { previousVersionFixture . RepoDirProvider . MicrosoftNETCoreAppVersion } ") ;
102+ . And . HaveStdErrContaining ( $ "--- Invoked apphost [version: { previousVersion } ") ;
100103 }
101104 }
102105
103106 public class SharedTestState : IDisposable
104107 {
105- private static RepoDirectoriesProvider RepoDirectories { get ; set ; }
106-
107- public TestProjectFixture Fixture60 { get ; }
108+ public TestApp App60 { get ; }
108109 public TestApp AppLatest { get ; }
109110
110111 private const string AppName = "HelloWorld" ;
111112
112113 public SharedTestState ( )
113114 {
114- RepoDirectories = new RepoDirectoriesProvider ( ) ;
115-
116- Fixture60 = CreateTestFixture ( "StandaloneApp6x" , "net6.0" , "6.0" ) ;
115+ App60 = TestApp . CreateFromBuiltAssets ( AppName , Path . Combine ( "SelfContained" , "net6.0" ) ) ;
117116
118117 AppLatest = TestApp . CreateFromBuiltAssets ( AppName ) ;
119118 AppLatest . PopulateSelfContained ( TestApp . MockedComponent . None ) ;
120119 }
121120
122121 public void Dispose ( )
123122 {
124- Fixture60 . Dispose ( ) ;
123+ App60 ? . Dispose ( ) ;
125124 AppLatest ? . Dispose ( ) ;
126125 }
127-
128- private static TestProjectFixture CreateTestFixture ( string testName , string netCoreAppFramework , string mnaVersion )
129- {
130- var repoDirectories = new RepoDirectoriesProvider ( microsoftNETCoreAppVersion : mnaVersion ) ;
131-
132- // Use standalone instead of framework-dependent for ease of deployment.
133- var publishFixture = new TestProjectFixture ( testName , repoDirectories , framework : netCoreAppFramework , assemblyName : AppName ) ;
134- publishFixture
135- . EnsureRestoredForRid ( publishFixture . CurrentRid )
136- . PublishProject ( runtime : publishFixture . CurrentRid , selfContained : true , extraArgs : $ "/p:AssemblyName={ AppName } ") ;
137-
138- return publishFixture ;
139- }
140126 }
141127 }
142128}
0 commit comments