mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-10-28 10:48:49 -04:00
21 lines
553 B
C#
21 lines
553 B
C#
using System.Threading.Channels;
|
|
using Shouldly;
|
|
|
|
namespace Cleanuparr.Infrastructure.Tests.TestHelpers;
|
|
|
|
/// <summary>
|
|
/// Assertions for channels used as in-process queues in tests.
|
|
/// </summary>
|
|
internal static class ChannelAssertions
|
|
{
|
|
/// <summary>
|
|
/// Asserts the channel holds exactly one message and returns it.
|
|
/// </summary>
|
|
internal static T ShouldHaveSingle<T>(this Channel<T> channel)
|
|
{
|
|
channel.Reader.Count.ShouldBe(1);
|
|
channel.Reader.TryRead(out T? item).ShouldBeTrue();
|
|
return item!;
|
|
}
|
|
}
|