Path: redb/redb.Tests.Integration/Tests/Unit/GlobalMetadataCacheTypesTests.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/GlobalMetadataCacheTypesTests.cs ---- using redb.Core.Caching; namespace redb.Tests.Integration.Tests.Unit; /// /// The _types table kept by the metadata cache of a domain: the materializer reads it from here instead of the /// database on every call. No database. /// public class GlobalMetadataCacheTypesTests { private static GlobalMetadataCache NewCache() => new("types-test-" + Guid.NewGuid().ToString("N")); private static readonly RedbTypeInfo[] Types = [ new() { Id = -9223372036854775700, Name = "String", DbType = "String", Type1 = "string" }, new() { Id = -9223372036854775704, Name = "Long", DbType = "Long", Type1 = "long" }, ]; [Fact] public void NothingCached_GivesNoTable() { NewCache().GetTypesById().Should().BeNull(); } [Fact] public void CachedTable_IsReturnedById() { var cache = NewCache(); cache.CacheTypesById(Types); var byId = cache.GetTypesById(); byId.Should().NotBeNull(); byId!.Should().HaveCount(2); byId[-9223372036854775704].Name.Should().Be("Long"); } [Fact] public void Clear_DropsTheTable() { var cache = NewCache(); cache.CacheTypesById(Types); cache.Clear(); cache.GetTypesById().Should().BeNull(); } [Fact] public void DisabledCache_GivesNoTable() { var cache = NewCache(); cache.CacheTypesById(Types); cache.SetEnabled(false); cache.GetTypesById().Should().BeNull(); } }