66using RustPlusBot . Abstractions . Events ;
77using RustPlusBot . Abstractions . Time ;
88using RustPlusBot . Domain . Alarms ;
9- using RustPlusBot . Domain . Connections ;
109using RustPlusBot . Features . Alarms . Posting ;
1110using RustPlusBot . Features . Alarms . Relaying ;
1211using RustPlusBot . Features . Alarms . Rendering ;
1312using RustPlusBot . Features . Connections . Listening ;
1413using RustPlusBot . Features . Workspace . Locating ;
1514using RustPlusBot . Localization ;
1615using RustPlusBot . Persistence . Alarms ;
17- using RustPlusBot . Persistence . Connections ;
1816using RustPlusBot . Persistence . Workspace ;
1917
2018namespace RustPlusBot . Features . Alarms . Tests ;
@@ -27,13 +25,11 @@ public sealed class AlarmStateRelayTests
2725 private static Harness Create ( SmartAlarm ? alarm = null , ulong ? channelId = 777UL )
2826 {
2927 var store = Substitute . For < IAlarmStore > ( ) ;
30- var connections = Substitute . For < IConnectionStore > ( ) ;
3128 var workspace = Substitute . For < IWorkspaceStore > ( ) ;
3229 workspace . GetCultureAsync ( Arg . Any < ulong > ( ) , Arg . Any < CancellationToken > ( ) ) . Returns ( "en" ) ;
3330
3431 var services = new ServiceCollection ( ) ;
3532 services . AddScoped ( _ => store ) ;
36- services . AddScoped ( _ => connections ) ;
3733 services . AddScoped ( _ => workspace ) ;
3834 var provider = services . BuildServiceProvider ( ) ;
3935 var scopeFactory = provider . GetRequiredService < IServiceScopeFactory > ( ) ;
@@ -67,7 +63,7 @@ private static Harness Create(SmartAlarm? alarm = null, ulong? channelId = 777UL
6763 clock ,
6864 NullLogger < AlarmStateRelay > . Instance ) ;
6965
70- return new Harness ( relay , store , refresher , poster , teamChatSender , connections ) ;
66+ return new Harness ( relay , store , refresher , poster , teamChatSender ) ;
7167 }
7268
7369 // ──────────────────────────────────────────────────────────────────────────
@@ -353,19 +349,13 @@ await h.Refresher.Received(1)
353349 // Connection status
354350 // ──────────────────────────────────────────────────────────────────────────
355351
356- /// <summary>Non-Connected server marks each alarm's embed as unreachable.</summary>
352+ /// <summary>Drop from Connected marks each alarm's embed as unreachable.</summary>
357353 [ Fact ]
358354 public async Task ConnectionStatus_not_connected_refreshes_all_alarms_unreachable ( )
359355 {
360356 var serverId = Guid . NewGuid ( ) ;
361357 var h = Create ( ) ;
362358
363- h . Connections . GetStateAsync ( 10UL , serverId , Arg . Any < CancellationToken > ( ) )
364- . Returns ( new ConnectionState
365- {
366- GuildId = 10UL , RustServerId = serverId , Status = ConnectionStatus . Unreachable ,
367- } ) ;
368-
369359 h . Store . ListByServerAsync ( 10UL , serverId , Arg . Any < CancellationToken > ( ) )
370360 . Returns (
371361 [
@@ -396,12 +386,6 @@ public async Task ConnectionStatus_connected_does_nothing()
396386 var serverId = Guid . NewGuid ( ) ;
397387 var h = Create ( ) ;
398388
399- h . Connections . GetStateAsync ( 10UL , serverId , Arg . Any < CancellationToken > ( ) )
400- . Returns ( new ConnectionState
401- {
402- GuildId = 10UL , RustServerId = serverId , Status = ConnectionStatus . Connected ,
403- } ) ;
404-
405389 await h . Relay . HandleConnectionStatusAsync (
406390 new ConnectionStatusChangedEvent ( 10UL , serverId , IsConnected : true , WasConnected : true ) ,
407391 CancellationToken . None ) ;
@@ -412,6 +396,30 @@ await h.Refresher.DidNotReceive()
412396 . RefreshAsync ( Arg . Any < SmartAlarm > ( ) , Arg . Any < bool > ( ) , Arg . Any < CancellationToken > ( ) ) ;
413397 }
414398
399+ /// <summary>Boot/reconnect-loop statuses (never Connected in this process) must not sweep — embeds keep their last-run state until the prime republishes.</summary>
400+ [ Fact ]
401+ public async Task ConnectionStatus_boot_without_prior_connection_does_not_sweep ( )
402+ {
403+ var serverId = Guid . NewGuid ( ) ;
404+ var h = Create ( ) ;
405+
406+ h . Store . ListByServerAsync ( 10UL , serverId , Arg . Any < CancellationToken > ( ) )
407+ . Returns (
408+ [
409+ new SmartAlarm
410+ {
411+ GuildId = 10UL , ServerId = serverId , EntityId = 42UL , Name = "A"
412+ } ,
413+ ] ) ;
414+
415+ await h . Relay . HandleConnectionStatusAsync (
416+ new ConnectionStatusChangedEvent ( 10UL , serverId , IsConnected : false , WasConnected : false ) ,
417+ CancellationToken . None ) ;
418+
419+ await h . Refresher . DidNotReceive ( )
420+ . RefreshAsync ( Arg . Any < SmartAlarm > ( ) , Arg . Any < bool > ( ) , Arg . Any < CancellationToken > ( ) ) ;
421+ }
422+
415423 // ──────────────────────────────────────────────────────────────────────────
416424 // Reachability changed
417425 // ──────────────────────────────────────────────────────────────────────────
@@ -464,6 +472,5 @@ private sealed record Harness(
464472 IAlarmStore Store ,
465473 IAlarmRefresher Refresher ,
466474 IAlarmChannelPoster Poster ,
467- IBotTeamChatSender TeamChatSender ,
468- IConnectionStore Connections ) ;
475+ IBotTeamChatSender TeamChatSender ) ;
469476}
0 commit comments