Files
Flypaper/test/Flypaper.Tests/Core/StrategySelectionTests.cs
TomandClaude Sonnet 5.5 c5167262b9
Build and deploy / build (push) Successful in 1m34s
Build and deploy / deploy (push) Successful in 20s
Remove the unused content choice and the plain-text hold method
The link labyrinth held every catch that mattered, text-drip was never
used. Flypaper__Drip__Content now only triggers the removed-settings warning.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 14:21:54 +01:00

49 lines
1.6 KiB
C#

using System.Net;
using System.Text;
using Flypaper.Core.Abstractions;
using Flypaper.Core.Models;
using Flypaper.Core.Runtime;
using Flypaper.Core.Strategies;
using Flypaper.Tests.Fakes;
using Shouldly;
namespace Flypaper.Tests.Core;
public sealed class StrategySelectionTests
{
private static readonly TrapContext Http =
new(new TrapSession(Guid.NewGuid(), TrapProtocol.Http, IPAddress.Parse("203.0.113.9"), DateTimeOffset.UtcNow));
[Fact]
public void Selects_the_html_page() =>
Selector().Select(Http).ShouldNotBeNull().Name.ShouldBe("html-drip");
[Fact]
public void Returns_nothing_for_unsupported_protocols()
{
var ssh = Http with { Session = Http.Session with { Protocol = TrapProtocol.Ssh } };
Selector().Select(ssh).ShouldBeNull();
}
[Fact]
public void Strategies_describe_themselves_with_their_parameters()
{
var options = TestOptions.Monitor(new DripOptions { MinDelay = TimeSpan.FromMilliseconds(100), MaxDelay = TimeSpan.FromMilliseconds(250), MinChunkSize = 2, MaxChunkSize = 8 });
var html = new HtmlDripStrategy(options, new SeededRandomSource(1), TimeProvider.System);
html.Describe().ShouldBe("html-drip 100-250ms 2-8B head 1024B");
html.MediaType.ShouldStartWith("text/html");
}
private static ConfiguredStrategySelector Selector()
{
var options = TestOptions.Monitor(new DripOptions());
var random = new SeededRandomSource(11);
return new ConfiguredStrategySelector(
[new HtmlDripStrategy(options, random, TimeProvider.System)],
options,
random);
}
}