1- // Licensed to the .NET Foundation under one or more agreements.
1+ // Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
44using System . Reflection ;
1111using Microsoft . Extensions . DependencyInjection . Extensions ;
1212using Xunit ;
1313
14- namespace Aspire . Dashboard . Tests . Integration . Playwright ;
14+ namespace Aspire . Dashboard . Tests . Integration . Playwright . Infrastructure ;
1515
1616public class DashboardServerFixture : IAsyncLifetime
1717{
18+ public Dictionary < string , string ? > Configuration { get ; }
19+
1820 public DashboardWebApplication DashboardApp { get ; private set ; } = null ! ;
1921
20- public Task InitializeAsync ( )
22+ // Can't have multiple fixtures when one is generic. Workaround by nesting playwright fixture.
23+ public PlaywrightFixture PlaywrightFixture { get ; }
24+
25+ public DashboardServerFixture ( )
2126 {
22- const string aspireDashboardAssemblyName = "Aspire.Dashboard" ;
23- var currentAssemblyName = Assembly . GetExecutingAssembly ( ) . GetName ( ) . Name ! ;
24- var currentAssemblyDirectory = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ! ;
25- var aspireAssemblyDirectory = currentAssemblyDirectory . Replace ( currentAssemblyName , aspireDashboardAssemblyName ) ;
27+ PlaywrightFixture = new PlaywrightFixture ( ) ;
2628
27- var initialData = new Dictionary < string , string ? >
29+ Configuration = new Dictionary < string , string ? >
2830 {
2931 [ DashboardConfigNames . DashboardFrontendUrlName . ConfigKey ] = "http://127.0.0.1:0" ,
3032 [ DashboardConfigNames . DashboardOtlpHttpUrlName . ConfigKey ] = "http://127.0.0.1:0" ,
3133 [ DashboardConfigNames . DashboardOtlpAuthModeName . ConfigKey ] = nameof ( OtlpAuthMode . Unsecured ) ,
3234 [ DashboardConfigNames . DashboardFrontendAuthModeName . ConfigKey ] = nameof ( FrontendAuthMode . Unsecured )
3335 } ;
36+ }
37+
38+ public async Task InitializeAsync ( )
39+ {
40+ await PlaywrightFixture . InitializeAsync ( ) ;
41+
42+ const string aspireDashboardAssemblyName = "Aspire.Dashboard" ;
43+ var currentAssemblyName = Assembly . GetExecutingAssembly ( ) . GetName ( ) . Name ! ;
44+ var currentAssemblyDirectory = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ! ;
45+ var aspireAssemblyDirectory = currentAssemblyDirectory . Replace ( currentAssemblyName , aspireDashboardAssemblyName ) ;
3446
35- var config = new ConfigurationManager ( ) . AddInMemoryCollection ( initialData ) . Build ( ) ;
47+ var config = new ConfigurationManager ( ) . AddInMemoryCollection ( Configuration ) . Build ( ) ;
3648
3749 // Add services to the container.
3850 DashboardApp = new DashboardWebApplication (
@@ -53,11 +65,12 @@ public Task InitializeAsync()
5365 builder . Services . AddSingleton < IDashboardClient , MockDashboardClient > ( ) ;
5466 } ) ;
5567
56- return DashboardApp . StartAsync ( ) ;
68+ await DashboardApp . StartAsync ( ) ;
5769 }
5870
59- public Task DisposeAsync ( )
71+ public async Task DisposeAsync ( )
6072 {
61- return DashboardApp . DisposeAsync ( ) . AsTask ( ) ;
73+ await DashboardApp . DisposeAsync ( ) ;
74+ await PlaywrightFixture . DisposeAsync ( ) ;
6275 }
6376}
0 commit comments