namespace Anubis.Tests; [TestClass] public sealed class PropertyTests { [TestMethod] [TestCategory(Category.Golden)] public void SplitMix64MatchesTheReferenceSequence() { // First output of the published SplitMix64 reference for seed 0. Assert.AreEqual(0xE220A8397B1DCDAFUL, new Gen(0).NextUInt64()); } [TestMethod] [TestCategory(Category.Unit)] public void SameSeedGivesTheSameSequence() { var a = new Gen(42); var b = new Gen(42); for (var i = 0; i < 100; i++) { Assert.AreEqual(a.NextUInt64(), b.NextUInt64()); } } [TestMethod] [TestCategory(Category.Unit)] public void IntegersStayInRange() { Property.ForAll(g => (Value: g.Int(-3, 4), Wide: g.Long(long.MinValue, long.MaxValue)), x => { Assert.IsTrue(x.Value is >= -3 and < 4, x.ToString()); Assert.AreNotEqual(long.MaxValue, x.Wide); }); } [TestMethod] [TestCategory(Category.Unit)] public void DecimalsRespectBoundsAndScale() { Property.ForAll(g => g.Decimal(0.00000001m, 70000m, 8), value => { Assert.IsTrue(value is >= 0.00000001m and <= 70000m); Assert.AreEqual(value, decimal.Round(value, 8)); }, cases: 1000); } [TestMethod] [TestCategory(Category.Unit)] public void DoublesAreInTheUnitInterval() { Property.ForAll(g => g.Double(), value => Assert.IsTrue(value is >= 0.0 and < 1.0)); } [TestMethod] [TestCategory(Category.Unit)] public void FailureNamesSeedAndCase() { var error = Assert.ThrowsExactly(() => Property.ForAll(g => g.Int(0, 10), value => Assert.IsTrue(value < 5), seed: 7)); Assert.Contains("seme 7", error.Message); } }