Add data management, randomized HTML drip and public README

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-11-14 16:08:45 +01:00
1 parent 3671019e60
commit f5d8ca7484
46 files changed
+1601 -172

No files matched your search

@@ -0,0 +1,58 @@
using Flypaper.Core.Strategies;
using Flypaper.Tests.Fakes;
using Shouldly;
namespace Flypaper.Tests.Core;
public sealed class HtmlContentTests
{
[Fact]
public void Starts_with_a_complete_html_head()
{
var head = HtmlContent.Generate(new SeededRandomSource(1)).First();
head.ShouldStartWith("<!doctype html>");
head.ShouldContain("<head>");
head.ShouldContain("<title>");
head.ShouldContain("<style>");
head.ShouldContain("</head>");
head.ShouldContain("<body>");
}
[Fact]
public void Keeps_generating_varied_body_content()
{
var body = string.Concat(HtmlContent.Generate(new SeededRandomSource(2)).Skip(1).Take(400));
body.ShouldContain("<main>");
body.ShouldContain("<h2>");
body.ShouldContain("<p>");
body.ShouldContain("<li><a href=\"/");
body.ShouldNotContain("</html>");
body.Length.ShouldBeGreaterThan(50_000);
}
[Fact]
public void Varies_sentence_and_paragraph_lengths()
{
var paragraphs = string.Concat(HtmlContent.Generate(new SeededRandomSource(3)).Take(300))
.Split("<p>", StringSplitOptions.RemoveEmptyEntries)
.Skip(1)
.Select(p => p[..p.IndexOf("</p>", StringComparison.Ordinal)])
.ToList();
paragraphs.Select(p => p.Length).Distinct().Count().ShouldBeGreaterThan(paragraphs.Count / 2);
paragraphs.Select(p => p.Count(c => c is '.' or '?')).Distinct().Count().ShouldBeGreaterThan(3);
}
[Fact]
public void Is_deterministic_for_the_same_random_source()
{
var first = string.Concat(HtmlContent.Generate(new SeededRandomSource(4)).Take(50));
var second = string.Concat(HtmlContent.Generate(new SeededRandomSource(4)).Take(50));
var other = string.Concat(HtmlContent.Generate(new SeededRandomSource(5)).Take(50));
second.ShouldBe(first);
other.ShouldNotBe(first);
}
}