mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-06-13 14:38:43 +00:00
Queue test
This commit is contained in:
@@ -29,8 +29,10 @@ await wh.Open();
|
||||
long memAfter = GC.GetTotalMemory(forceFullCollection: true);
|
||||
double memMB = (memAfter - memBefore) / (1024.0 * 1024.0);
|
||||
|
||||
Console.WriteLine("Press ENTER to stop.");
|
||||
Console.ReadLine();
|
||||
Console.WriteLine("Ready. Press Ctrl+C to stop.");
|
||||
var stop = new TaskCompletionSource();
|
||||
Console.CancelKeyPress += (_, e) => { e.Cancel = true; stop.TrySetResult(); };
|
||||
await stop.Task;
|
||||
await wh.Close();
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,26 @@ public class AsyncQueueTests
|
||||
Assert.Empty(queue.DrainProcessed());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrainProcessed_PreservesExplicitResourceWorkFlag()
|
||||
{
|
||||
var queue = new AsyncQueue<int>();
|
||||
queue.SetProcessedCapture(true);
|
||||
|
||||
queue.Add(new AsyncReply<int>(1), hasResource: false);
|
||||
|
||||
var pending = new AsyncReply<int>();
|
||||
queue.Add(pending, hasResource: true);
|
||||
pending.Trigger(2);
|
||||
|
||||
var processed = queue.DrainProcessed();
|
||||
|
||||
Assert.Collection(
|
||||
processed,
|
||||
x => Assert.False(x.HasResource),
|
||||
x => Assert.True(x.HasResource));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DisablingCapture_DiscardsHistoryAndStopsCapturing()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user