Files
Flypaper/test/Flypaper.Tests/Web/StrategyNamesTests.cs
T

67 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Flypaper.Core.Strategies;
using Flypaper.Web.Components.Shared;
using Shouldly;
namespace Flypaper.Tests.Web;
public sealed class StrategyNamesTests
{
[Fact]
public void Describes_the_maze_with_all_suffixes()
{
var info = StrategyNames.Describe("maze-drip 50-500ms 1-1024B head 1024B link 160B repeat");
info.DisplayName.ShouldBe("Link-Labyrinth");
info.Explanation.ShouldNotBeNull();
info.Details.ShouldBe([
"tröpfelt 1–1.024 Byte alle 50–500 ms",
"schneller Start: die ersten 1.024 Byte sofort",
"alle 160 Byte ein Link",
"Wiederholer: darf länger festgehalten werden"
]);
info.Raw.ShouldBe("maze-drip 50-500ms 1-1024B head 1024B link 160B repeat");
info.Tooltip.ShouldContain("Technisch: maze-drip 50-500ms");
}
[Fact]
public void Shows_unknown_names_and_tokens_unchanged()
{
var info = StrategyNames.Describe("ufo-drip 5-9ms 1-2B odd");
info.DisplayName.ShouldBe("ufo-drip");
info.Explanation.ShouldBeNull();
info.Details.ShouldBe(["tröpfelt 1–2 Byte alle 5–9 ms", "odd"]);
}
[Theory]
[InlineData("robots-static")]
[InlineData("robots-bait 10-20ms 1-8B link 160B")]
public void Covers_robots_strategies(string strategy) =>
StrategyNames.Describe(strategy).Explanation.ShouldNotBeNull();
[Fact]
public void Covers_every_strategy_name_of_the_core()
{
string[] names =
[
MazeDripStrategy.PageName, MazeDripStrategy.ListingName, MazeDripStrategy.BaitName,
HtmlDripStrategy.StrategyName, TextDripStrategy.StrategyName, RobotsStaticStrategy.StrategyName,
.. FileContent.Profiles.Select(profile => profile.Name)
];
foreach (var name in names)
{
StrategyNames.Describe(name).Explanation.ShouldNotBeNull(name);
}
}
[Fact]
public void Finds_base_names_by_display_name()
{
StrategyNames.Matching(" gefälschtes git ").ShouldBe(["git-drip"]);
StrategyNames.Matching("zugangsdaten").ShouldBe(["env-drip"]);
StrategyNames.Matching("").ShouldBeEmpty();
StrategyNames.Matching("nichts").ShouldBeEmpty();
}
}