25 lines
691 B
C#
25 lines
691 B
C#
using System.Collections.Concurrent;
|
|
using System.Net;
|
|
using Flypaper.Core.Abstractions;
|
|
using Flypaper.Core.Models;
|
|
|
|
namespace Flypaper.Tests.Fakes;
|
|
|
|
internal sealed class FakeTrapChannel : ITrapChannel
|
|
{
|
|
public TrapSession Session { get; } = new(Guid.NewGuid(), TrapProtocol.Http, IPAddress.Loopback, DateTimeOffset.UtcNow);
|
|
|
|
public string? Path { get; init; }
|
|
|
|
public string? Host { get; init; }
|
|
|
|
public ConcurrentQueue<byte[]> Writes { get; } = new();
|
|
|
|
public ValueTask WriteAsync(ReadOnlyMemory<byte> data, CancellationToken ct)
|
|
{
|
|
ct.ThrowIfCancellationRequested();
|
|
Writes.Enqueue(data.ToArray());
|
|
return ValueTask.CompletedTask;
|
|
}
|
|
}
|