using System.Globalization; namespace Anubis.Tests; /// /// Property tests without external packages (ADR 0003, 0004): many generated cases from a fixed /// seed, so a failure always repeats, and a message that names the seed and the failing case. /// internal static class Property { public const int DefaultSeed = 20261110; public const int DefaultCases = 200; public static void ForAll(Func generate, Action property, int cases = DefaultCases, int seed = DefaultSeed) { var gen = new Gen(seed); for (var i = 0; i < cases; i++) { var value = generate(gen); try { property(value); } catch (Exception ex) when (ex is not AssertInconclusiveException) { throw new AssertFailedException( string.Create(CultureInfo.InvariantCulture, $"Proprietà violata al caso {i} (seme {seed}): {value}"), ex); } } } }