File tree Expand file tree Collapse file tree 6 files changed +47
-7
lines changed
Expand file tree Collapse file tree 6 files changed +47
-7
lines changed Original file line number Diff line number Diff line change @@ -339,3 +339,6 @@ ASALocalRun/
339339# BeatPulse healthcheck temp database
340340healthchecksdb
341341* .snk
342+
343+ # Ignore user config file
344+ /src /SocketIOClient.Test /user.json
Original file line number Diff line number Diff line change 1+ namespace SocketIOClient . Test . Configuration
2+ {
3+ public class UserConfig
4+ {
5+ public bool RunServers { get ; set ; } = false ;
6+ public bool StopServersAfterRun { get ; set ; } = false ;
7+ }
8+ }
Original file line number Diff line number Diff line change 1+ using System . IO ;
2+
3+ namespace SocketIOClient . Test . Configuration
4+ {
5+ public class UserConfigManager
6+ {
7+ private const string configFileName = "user.json" ;
8+
9+ public bool Exists => File . Exists ( configFileName ) ;
10+
11+ public UserConfig Get ( )
12+ {
13+ if ( ! this . Exists )
14+ {
15+ return null ;
16+ }
17+
18+ return System . Text . Json . JsonSerializer . Deserialize < UserConfig > ( File . ReadAllText ( configFileName ) ) ;
19+ }
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ // Rename "user_sample.json" to "user.json" and copy to output directory (comment must be removed)
2+ {
3+ "RunServers" : true ,
4+ "StopServersAfterRun" : true
5+ }
Original file line number Diff line number Diff line change 2828 <None Update =" Files\tianlongbabu.epub" >
2929 <CopyToOutputDirectory >PreserveNewest</CopyToOutputDirectory >
3030 </None >
31+ <None Update =" user.json" >
32+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
33+ </None >
3134 </ItemGroup >
3235
3336</Project >
Original file line number Diff line number Diff line change 11using Microsoft . VisualStudio . TestTools . UnitTesting ;
2+ using SocketIOClient . Test . Configuration ;
23using SocketIOClient . Test . SocketIOTests . V4 ;
34using System ;
45using System . Collections . Generic ;
@@ -17,10 +18,14 @@ public class AssemblyIntegrationTest
1718 new ServerV4Manager ( )
1819 } ;
1920
21+ private static UserConfig UserConfig => new UserConfigManager ( ) . Get ( ) ?? new UserConfig ( ) ;
22+
23+ private static bool IsRunningOnAzureDevOps => Environment . GetEnvironmentVariable ( "SYSTEM_DEFINITIONID" ) != null ;
24+
2025 [ AssemblyInitialize ]
2126 public static void Initialize ( TestContext context )
2227 {
23- if ( ! IsRunningOnAzureDevOps ( ) )
28+ if ( ! IsRunningOnAzureDevOps && UserConfig . RunServers )
2429 {
2530 foreach ( var server in Servers )
2631 {
@@ -35,18 +40,13 @@ public static void Initialize(TestContext context)
3540 [ AssemblyCleanup ]
3641 public static void Cleanup ( )
3742 {
38- if ( ! IsRunningOnAzureDevOps ( ) )
43+ if ( ! IsRunningOnAzureDevOps && UserConfig . RunServers && UserConfig . StopServersAfterRun )
3944 {
4045 foreach ( var server in Servers )
4146 {
4247 server . Destroy ( ) ;
4348 }
4449 }
4550 }
46-
47- private static bool IsRunningOnAzureDevOps ( )
48- {
49- return Environment . GetEnvironmentVariable ( "SYSTEM_DEFINITIONID" ) != null ;
50- }
5151 }
5252}
You can’t perform that action at this time.
0 commit comments