22using NSubstitute ;
33using RustPlusBot . Abstractions . Connections ;
44using RustPlusBot . Abstractions . Events ;
5- using RustPlusBot . Domain . Connections ;
65using RustPlusBot . Domain . StorageMonitors ;
76using RustPlusBot . Features . ItemData . Naming ;
87using RustPlusBot . Features . StorageMonitors . Posting ;
@@ -24,13 +23,11 @@ public sealed class StorageMonitorStateRelayTests
2423 private static Harness Create ( )
2524 {
2625 var store = Substitute . For < IStorageMonitorStore > ( ) ;
27- var connections = Substitute . For < IConnectionStore > ( ) ;
2826 var workspace = Substitute . For < IWorkspaceStore > ( ) ;
2927 workspace . GetCultureAsync ( Arg . Any < ulong > ( ) , Arg . Any < CancellationToken > ( ) ) . Returns ( "en" ) ;
3028
3129 var services = new ServiceCollection ( ) ;
3230 services . AddScoped ( _ => store ) ;
33- services . AddScoped ( _ => connections ) ;
3431 services . AddScoped ( _ => workspace ) ;
3532 var provider = services . BuildServiceProvider ( ) ;
3633
@@ -49,7 +46,7 @@ private static Harness Create()
4946 var relay = new StorageMonitorStateRelay (
5047 provider . GetRequiredService < IServiceScopeFactory > ( ) , locator , poster , renderer , query ) ;
5148
52- return new Harness ( relay , store , poster , connections , query ) ;
49+ return new Harness ( relay , store , poster , query ) ;
5350 }
5451
5552 [ Fact ]
@@ -95,11 +92,6 @@ await h.Poster.Received(1).EnsureAsync(555UL, Arg.Any<ulong?>(),
9592 public async Task HandleConnectionStatusAsync_NotConnected_PostsUnreachable ( )
9693 {
9794 var h = Create ( ) ;
98- h . Connections . GetStateAsync ( Guild , Server , Arg . Any < CancellationToken > ( ) )
99- . Returns ( new ConnectionState
100- {
101- GuildId = Guild , RustServerId = Server , Status = ConnectionStatus . Unreachable ,
102- } ) ;
10395 h . Store . ListByServerAsync ( Guild , Server , Arg . Any < CancellationToken > ( ) )
10496 . Returns (
10597 [
@@ -126,11 +118,6 @@ await h.Poster.Received(1).EnsureAsync(555UL, Arg.Any<ulong?>(),
126118 public async Task HandleConnectionStatusAsync_Connected_DoesNothing ( )
127119 {
128120 var h = Create ( ) ;
129- h . Connections . GetStateAsync ( Guild , Server , Arg . Any < CancellationToken > ( ) )
130- . Returns ( new ConnectionState
131- {
132- GuildId = Guild , RustServerId = Server , Status = ConnectionStatus . Connected ,
133- } ) ;
134121
135122 await h . Relay . HandleConnectionStatusAsync (
136123 new ConnectionStatusChangedEvent ( Guild , Server , IsConnected : true , WasConnected : true ) ,
@@ -141,6 +128,33 @@ await h.Poster.DidNotReceive().EnsureAsync(Arg.Any<ulong>(), Arg.Any<ulong?>(),
141128 Arg . Any < CancellationToken > ( ) ) ;
142129 }
143130
131+ /// <summary>Boot/reconnect-loop statuses (never Connected in this process) must not sweep — embeds keep their last-run state until the prime republishes.</summary>
132+ [ Fact ]
133+ public async Task HandleConnectionStatusAsync_BootWithoutPriorConnection_DoesNothing ( )
134+ {
135+ var h = Create ( ) ;
136+ h . Store . ListByServerAsync ( Guild , Server , Arg . Any < CancellationToken > ( ) )
137+ . Returns (
138+ [
139+ new SmartStorageMonitor
140+ {
141+ GuildId = Guild ,
142+ ServerId = Server ,
143+ EntityId = 7UL ,
144+ Name = "TC" ,
145+ MessageId = null ,
146+ } ,
147+ ] ) ;
148+
149+ await h . Relay . HandleConnectionStatusAsync (
150+ new ConnectionStatusChangedEvent ( Guild , Server , IsConnected : false , WasConnected : false ) ,
151+ CancellationToken . None ) ;
152+
153+ await h . Poster . DidNotReceive ( ) . EnsureAsync ( Arg . Any < ulong > ( ) , Arg . Any < ulong ? > ( ) ,
154+ Arg . Any < global ::Discord . Embed > ( ) , Arg . Any < global ::Discord . MessageComponent > ( ) ,
155+ Arg . Any < CancellationToken > ( ) ) ;
156+ }
157+
144158 [ Fact ]
145159 public async Task HandleReachabilityChangedAsync_ForeignEntity_DoesNothing ( )
146160 {
@@ -243,6 +257,5 @@ private sealed record Harness(
243257 StorageMonitorStateRelay Relay ,
244258 IStorageMonitorStore Store ,
245259 IStorageMonitorChannelPoster Poster ,
246- IConnectionStore Connections ,
247260 IRustServerQuery Query ) ;
248261}
0 commit comments