Restructure solution into folders and fix persistence issues

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-11-14 14:10:24 +01:00
1 parent 37987a394a
commit 7c39cb5562
62 files changed
+219 -151

No files matched your search

@@ -0,0 +1,43 @@
using Flypaper.Core.Models;
using Flypaper.Core.Strategies;
using Flypaper.Tests.Fakes;
using Shouldly;
namespace Flypaper.Tests.Core;
public sealed class DripStrategyTests
{
[Fact]
public async Task Drips_single_bytes_until_cancelled()
{
var strategy = CreateStrategy(TimeSpan.FromMilliseconds(20));
var channel = new FakeTrapChannel();
using var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(300));
await Should.ThrowAsync<OperationCanceledException>(() => strategy.RunAsync(channel, cts.Token));
channel.Writes.Count.ShouldBeInRange(3, 20);
channel.Writes.ShouldAllBe(write => write.Length == 1);
}
[Fact]
public async Task Writes_first_byte_immediately()
{
var strategy = CreateStrategy(TimeSpan.FromMinutes(1));
var channel = new FakeTrapChannel();
using var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(100));
await Should.ThrowAsync<OperationCanceledException>(() => strategy.RunAsync(channel, cts.Token));
channel.Writes.Count.ShouldBe(1);
}
[Theory]
[InlineData(TrapProtocol.Http, true)]
[InlineData(TrapProtocol.Ssh, false)]
public void Supports_only_http(TrapProtocol protocol, bool expected) =>
CreateStrategy(TimeSpan.FromSeconds(1)).Supports(protocol).ShouldBe(expected);
private static DripStrategy CreateStrategy(TimeSpan interval) =>
new(TestOptions.Monitor(new DripOptions { Interval = interval }), TimeProvider.System);
}