diff --git a/tests/ScadaLink.SiteRuntime.Tests/Actors/InstanceActorIntegrationTests.cs b/tests/ScadaLink.SiteRuntime.Tests/Actors/InstanceActorIntegrationTests.cs index 0bc84b1..68543f9 100644 --- a/tests/ScadaLink.SiteRuntime.Tests/Actors/InstanceActorIntegrationTests.cs +++ b/tests/ScadaLink.SiteRuntime.Tests/Actors/InstanceActorIntegrationTests.cs @@ -123,11 +123,9 @@ public class InstanceActorIntegrationTests : TestKit, IDisposable $"corr-{i}", "Pump1", "Temperature", $"{i}", DateTimeOffset.UtcNow)); } - // Wait for all to process - for (int i = 0; i < 50; i++) - { - ExpectMsg(TimeSpan.FromSeconds(10)); - } + // SetStaticAttributeCommand is fire-and-forget; the GetAttributeRequest + // round-trip below is the sync point — the FIFO mailbox guarantees all + // 50 sets are processed before the get is. // The last value should be the final one actor.Tell(new GetAttributeRequest( diff --git a/tests/ScadaLink.SiteRuntime.Tests/Actors/InstanceActorTests.cs b/tests/ScadaLink.SiteRuntime.Tests/Actors/InstanceActorTests.cs index 20b5254..e205f5e 100644 --- a/tests/ScadaLink.SiteRuntime.Tests/Actors/InstanceActorTests.cs +++ b/tests/ScadaLink.SiteRuntime.Tests/Actors/InstanceActorTests.cs @@ -113,13 +113,12 @@ public class InstanceActorTests : TestKit, IDisposable var actor = CreateInstanceActor("Pump1", config); - // Set a static attribute -- response comes async via PipeTo + // SetStaticAttributeCommand is fire-and-forget (no reply); the + // GetAttributeRequest round-trip below confirms it was applied — the + // actor mailbox is FIFO, so the set is processed before the get. actor.Tell(new SetStaticAttributeCommand( "corr-3", "Pump1", "Temperature", "100.0", DateTimeOffset.UtcNow)); - var setResponse = ExpectMsg(TimeSpan.FromSeconds(5)); - Assert.True(setResponse.Success); - // Verify the value changed in memory actor.Tell(new GetAttributeRequest( "corr-4", "Pump1", "Temperature", DateTimeOffset.UtcNow)); @@ -146,9 +145,12 @@ public class InstanceActorTests : TestKit, IDisposable actor.Tell(new SetStaticAttributeCommand( "corr-persist", "PumpPersist1", "Temperature", "100.0", DateTimeOffset.UtcNow)); - ExpectMsg(TimeSpan.FromSeconds(5)); - - // Give async persistence time to complete + // SetStaticAttributeCommand is fire-and-forget; round-trip a + // GetAttributeRequest to confirm the command was processed (FIFO + // mailbox), then wait for the async SQLite persist to complete. + actor.Tell(new GetAttributeRequest( + "corr-persist-get", "PumpPersist1", "Temperature", DateTimeOffset.UtcNow)); + ExpectMsg(TimeSpan.FromSeconds(5)); await Task.Delay(500); // Verify it persisted to SQLite