@@ -43,7 +43,8 @@ private static Harness CreateHarness(FakeRustSocketSource source)
4343 services . AddScoped ( sp => new BotDbContext (
4444 new DbContextOptionsBuilder < BotDbContext > ( ) . UseSqlite ( sp . GetRequiredService < SqliteConnection > ( ) ) . Options ) ) ;
4545 services . AddScoped < IConnectionStore , ConnectionStore > ( ) ;
46- services . AddScoped < RustPlusBot . Persistence . Servers . IServerService , RustPlusBot . Persistence . Servers . ServerService > ( ) ;
46+ services
47+ . AddScoped < RustPlusBot . Persistence . Servers . IServerService , RustPlusBot . Persistence . Servers . ServerService > ( ) ;
4748
4849 services . AddSingleton < IRustSocketSource > ( source ) ;
4950 services . AddSingleton ( Options . Create ( new ConnectionOptions
@@ -57,33 +58,50 @@ private static Harness CreateHarness(FakeRustSocketSource source)
5758 services . AddSingleton < ConnectionSupervisor > ( ) ;
5859
5960 var provider = services . BuildServiceProvider ( ) ;
60- return new Harness { Provider = provider , Dm = dm , Supervisor = provider . GetRequiredService < ConnectionSupervisor > ( ) } ;
61+ return new Harness
62+ {
63+ Provider = provider , Dm = dm , Supervisor = provider . GetRequiredService < ConnectionSupervisor > ( )
64+ } ;
6165 }
6266
6367 private static async Task < ( Guid ServerId , Guid CredA , Guid CredB ) > SeedAsync (
64- ServiceProvider provider , CredentialStatus bStatus = CredentialStatus . Standby )
68+ ServiceProvider provider ,
69+ CredentialStatus bStatus = CredentialStatus . Standby )
6570 {
6671 using var scope = provider . CreateScope ( ) ;
6772 var context = scope . ServiceProvider . GetRequiredService < BotDbContext > ( ) ;
68- var server = new RustServer { GuildId = 10UL , Name = "S" , Ip = "1.1.1.1" , Port = 28015 } ;
73+ var server = new RustServer
74+ {
75+ GuildId = 10UL , Name = "S" , Ip = "1.1.1.1" , Port = 28015
76+ } ;
6977 context . RustServers . Add ( server ) ;
7078 var a = new PlayerCredential
7179 {
72- GuildId = 10UL , RustServerId = server . Id , OwnerUserId = 1UL , SteamId = 100UL ,
73- ProtectedPlayerToken = "111" , Status = CredentialStatus . Active ,
80+ GuildId = 10UL ,
81+ RustServerId = server . Id ,
82+ OwnerUserId = 1UL ,
83+ SteamId = 100UL ,
84+ ProtectedPlayerToken = "111" ,
85+ Status = CredentialStatus . Active ,
7486 } ;
7587 var b = new PlayerCredential
7688 {
77- GuildId = 10UL , RustServerId = server . Id , OwnerUserId = 2UL , SteamId = 200UL ,
78- ProtectedPlayerToken = "222" , Status = bStatus ,
89+ GuildId = 10UL ,
90+ RustServerId = server . Id ,
91+ OwnerUserId = 2UL ,
92+ SteamId = 200UL ,
93+ ProtectedPlayerToken = "222" ,
94+ Status = bStatus ,
7995 } ;
8096 await context . PlayerCredentials . AddRangeAsync ( a , b ) ;
8197 await context . SaveChangesAsync ( ) ;
8298 return ( server . Id , a . Id , b . Id ) ;
8399 }
84100
85101 private static async Task < ConnectionState ? > WaitForStateAsync (
86- ServiceProvider provider , Guid serverId , Func < ConnectionState , bool > predicate )
102+ ServiceProvider provider ,
103+ Guid serverId ,
104+ Func < ConnectionState , bool > predicate )
87105 {
88106 var deadline = DateTimeOffset . UtcNow . AddSeconds ( 20 ) ;
89107 while ( DateTimeOffset . UtcNow < deadline )
@@ -130,7 +148,7 @@ public async Task Connect_AuthRejected_FailsOverToNextStandbyAndDmsOwner()
130148 {
131149 var source = new FakeRustSocketSource ( ) ;
132150 source . EnqueueConnect ( SocketConnectOutcome . AuthRejected ) ; // credential A
133- source . EnqueueConnect ( SocketConnectOutcome . Connected ) ; // credential B
151+ source . EnqueueConnect ( SocketConnectOutcome . Connected ) ; // credential B
134152 source . EnqueueHeartbeat ( HeartbeatResult . Ok ( 3 ) ) ;
135153 await using var h = CreateHarness ( source ) ;
136154 var ( serverId , credA , credB ) = await SeedAsync ( h . Provider ) ;
@@ -181,8 +199,8 @@ public async Task Heartbeat_Unreachable_ReconnectsAndRecovers()
181199 {
182200 var source = new FakeRustSocketSource ( ) ;
183201 source . EnqueueConnect ( SocketConnectOutcome . Connected ) ;
184- source . EnqueueHeartbeat ( HeartbeatResult . Ok ( 2 ) ) ; // first heartbeat -> Connected
185- source . EnqueueHeartbeat ( HeartbeatResult . Unreachable ) ; // next heartbeat -> drop
202+ source . EnqueueHeartbeat ( HeartbeatResult . Ok ( 2 ) ) ; // first heartbeat -> Connected
203+ source . EnqueueHeartbeat ( HeartbeatResult . Unreachable ) ; // next heartbeat -> drop
186204 source . EnqueueConnect ( SocketConnectOutcome . Connected ) ; // reconnect
187205 source . EnqueueHeartbeat ( HeartbeatResult . Ok ( 4 ) ) ;
188206 await using var h = CreateHarness ( source ) ;
0 commit comments