test(streaming): close lifecycle gate after cutover
This commit is contained in:
parent
db3ca59fd0
commit
4a205a3e56
7 changed files with 173 additions and 17 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System.Net;
|
||||
using AcDream.App.Net;
|
||||
using AcDream.App.Rendering;
|
||||
using AcDream.Core.Net;
|
||||
using AcDream.Core.Net.Messages;
|
||||
using AcDream.UI.Abstractions;
|
||||
|
|
@ -833,6 +834,48 @@ public sealed class LiveSessionControllerTests
|
|||
Assert.Throws<ObjectDisposedException>(() => controller.Start(LiveOptions(), host));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReentrantShutdownRetainsControllerAndDependentsUntilDeferredDisposeCompletes()
|
||||
{
|
||||
var calls = new List<string>();
|
||||
var operations = new TestOperations(calls);
|
||||
var host = new TestHost(calls);
|
||||
var controller = new LiveSessionController(operations);
|
||||
controller.Start(LiveOptions(), host);
|
||||
bool dependentDisposed = false;
|
||||
var shutdown = new ResourceShutdownTransaction(
|
||||
new ResourceShutdownStage("session lifetime",
|
||||
[
|
||||
new("live session", () =>
|
||||
{
|
||||
controller.Dispose();
|
||||
if (!controller.IsDisposalComplete)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"live-session disposal is still deferred");
|
||||
}
|
||||
}),
|
||||
]),
|
||||
new ResourceShutdownStage("session dependents",
|
||||
[
|
||||
new("streamer", () => dependentDisposed = true),
|
||||
]));
|
||||
operations.OnTick = () =>
|
||||
{
|
||||
Assert.Throws<AggregateException>(shutdown.CompleteOrThrow);
|
||||
Assert.Equal(0, shutdown.CurrentStage);
|
||||
Assert.False(dependentDisposed);
|
||||
};
|
||||
|
||||
controller.Tick();
|
||||
|
||||
Assert.True(controller.IsDisposalComplete);
|
||||
Assert.False(dependentDisposed);
|
||||
shutdown.CompleteOrThrow();
|
||||
Assert.True(shutdown.IsComplete);
|
||||
Assert.True(dependentDisposed);
|
||||
}
|
||||
|
||||
private static RuntimeOptions LiveOptions(
|
||||
bool live = true,
|
||||
string? user = "user")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue