Add data management, randomized HTML drip and public README
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3671019e60
commit
f5d8ca7484
46 files changed
+1601
-172
No files matched your search
@@ -0,0 +1,35 @@
|
||||
using System.Text;
|
||||
using Flypaper.Core.Models;
|
||||
using Flypaper.Core.Strategies;
|
||||
using Flypaper.Tests.Fakes;
|
||||
using Shouldly;
|
||||
|
||||
namespace Flypaper.Tests.Core;
|
||||
|
||||
public sealed class HtmlDripStrategyTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Drips_html_in_small_chunks_until_cancelled()
|
||||
{
|
||||
var strategy = CreateStrategy();
|
||||
var channel = new FakeTrapChannel();
|
||||
using var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(300));
|
||||
|
||||
await Should.ThrowAsync<OperationCanceledException>(() => strategy.RunAsync(channel, cts.Token));
|
||||
|
||||
channel.Writes.Count.ShouldBeGreaterThan(5);
|
||||
channel.Writes.ShouldAllBe(write => write.Length >= 1 && write.Length <= 64);
|
||||
Encoding.UTF8.GetString(channel.Writes.SelectMany(write => write).ToArray()).ShouldStartWith("<!doctype html>");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(TrapProtocol.Http, true)]
|
||||
[InlineData(TrapProtocol.Ssh, false)]
|
||||
public void Supports_only_http(TrapProtocol protocol, bool expected) =>
|
||||
CreateStrategy().Supports(protocol).ShouldBe(expected);
|
||||
|
||||
private static HtmlDripStrategy CreateStrategy() => new(
|
||||
TestOptions.Monitor(new DripOptions { MinDelay = TimeSpan.FromMilliseconds(1), MaxDelay = TimeSpan.FromMilliseconds(5) }),
|
||||
new SeededRandomSource(21),
|
||||
TimeProvider.System);
|
||||
}
|
||||
Reference in new issue
Block a user