acdream/tests/AcDream.Runtime.Tests/Session/LiveSessionSubscriptionSetTests.cs
Erik 7593078774 refactor(runtime): move session lifetime and ordered transport
Move the canonical WorldSession generation, connect/enter/tick/stop transaction, inbound subscription owner, and retryable teardown acknowledgements into AcDream.Runtime. Keep App as a borrowing graphical host with a single inertable command projection and no mirrored session state.

Validated by 79 Runtime tests, 3,776 App tests with three existing skips, the Release solution build, and 8,428 complete Release tests with five existing skips.

Co-authored-by: Codex <codex@openai.com>
2026-07-25 19:39:24 +02:00

60 lines
1.8 KiB
C#

using AcDream.Runtime.Session;
namespace AcDream.Runtime.Tests.Session;
public sealed class LiveSessionSubscriptionSetTests
{
[Fact]
public void Dispose_RetriesOnlyFailedEdgesUntilTheyConverge()
{
var order = new List<int>();
var subscriptions = new LiveSessionSubscriptionSet();
subscriptions.Add(() => order.Add(1));
int secondFailures = 1;
subscriptions.Add(() =>
{
order.Add(2);
if (secondFailures-- > 0)
throw new InvalidOperationException("second failed");
});
int thirdFailures = 1;
subscriptions.Add(() =>
{
order.Add(3);
if (thirdFailures-- > 0)
throw new IOException("third failed");
});
AggregateException error = Assert.Throws<AggregateException>(
subscriptions.Dispose);
Assert.Equal([3, 2, 1], order);
Assert.Collection(
error.InnerExceptions,
exception => Assert.IsType<IOException>(exception),
exception => Assert.IsType<InvalidOperationException>(exception));
subscriptions.Dispose();
subscriptions.Dispose();
Assert.Equal([3, 2, 1, 3, 2], order);
}
[Fact]
public void Dispose_PersistentFailureNeverReplaysSuccessfulEdges()
{
var order = new List<int>();
var subscriptions = new LiveSessionSubscriptionSet();
subscriptions.Add(() => order.Add(1));
subscriptions.Add(() =>
{
order.Add(2);
throw new InvalidOperationException("persistent");
});
Assert.Throws<AggregateException>(subscriptions.Dispose);
Assert.Throws<AggregateException>(subscriptions.Dispose);
Assert.Equal([2, 1, 2], order);
}
}