Path: redb/redb.Tests.Integration/Tests/Unit/ProFreeOfChargeTests.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Unit/ProFreeOfChargeTests.cs ---- using System.Reflection; namespace redb.Tests.Integration.Tests.Unit; /// /// redb Pro is free of charge, whatever the version of the package: a build of any major version runs every Pro /// feature, and nothing is refused or counted. The policy and the guard are internal, so the test reaches them by /// reflection and hands them the version a package of a higher major would pass. /// [Collection("LicenseState")] public class ProFreeOfChargeTests { private static readonly Assembly Licensing = typeof(redb.Licensing.LicenseStore).Assembly; private static readonly Assembly CorePro = typeof(redb.Core.Pro.Extensions.RedbProServiceCollectionExtensions).Assembly; private static Type Policy => Licensing.GetType("redb.Licensing.LicensePolicy", throwOnError: true)!; private static Type Guard => CorePro.GetType("redb.Core.Pro.Licensing.LicenseGuard", throwOnError: true)!; [Theory] [InlineData(4)] [InlineData(5)] [InlineData(99)] public void Policy_TreatsEveryMajorAsFree(int major) { var isFree = Policy.GetMethod("IsFreeVersion", BindingFlags.Public | BindingFlags.Static)!; ((bool)isFree.Invoke(null, [new Version(major, 0, 0)])!).Should().BeTrue(); } [Theory] [InlineData(5)] [InlineData(99)] public void Guard_WithoutAKey_RefusesNothing_AndCountsNothing(int major) { redb.Licensing.LicenseStore.Reset(); redb.Licensing.LicenseStore.All.Should().BeEmpty("the test host sets no key"); var check = Guard.GetMethod("CheckFeature", BindingFlags.NonPublic | BindingFlags.Static)!; var dailyLimit = (int)Guard.GetField("DailyLimit", BindingFlags.NonPublic | BindingFlags.Static)!.GetRawConstantValue()!; var counter = Guard.GetField("_requestCount", BindingFlags.NonPublic | BindingFlags.Static)!; var before = (int)counter.GetValue(null)!; // Past the old daily trial limit: the dormant path would have thrown LicenseRequiredException here. var version = new Version(major, 0, 0); var act = () => { for (var i = 0; i < dailyLimit + 10; i++) check.Invoke(null, ["core.pro", version]); }; act.Should().NotThrow(); ((int)counter.GetValue(null)!).Should().Be(before, "no request is counted"); } }