public void TestManifestUpdates(int familyLen) { var family = new byte[familyLen]; using var ms = new KeepOpenMemoryStream(); var expectedIds = new List <ulong>(); using (var manifest = new Manifest(new DirectoryInfo("."), ms, new PlaneDBOptions().EnableCompression())) { for (byte l = 0; l < 128; ++l) { var level = new List <ulong>(); for (var i = 0; i < COUNT; ++i) { var id = manifest.AllocateIdentifier(); if (i > 0) { expectedIds.Add(id); } level.Add(id); } manifest.CommitLevel(family, l, level.ToArray()); level.RemoveAt(0); manifest.CommitLevel(family, l, level.ToArray()); } } using (var manifest = new Manifest(new DirectoryInfo("."), ms, new PlaneDBOptions().EnableCompression())) { var seq = manifest.Sequence(family); Assert.IsTrue(expectedIds.SequenceEqual(seq.OrderBy(i => i))); } }
public void TestManfiestWrongOptions() { using var ms = new KeepOpenMemoryStream(); using (var manifest = new Manifest(new DirectoryInfo("."), ms, new PlaneDBOptions().EnableCompression())) { for (byte l = 0; l < 128; ++l) { var level = new List <ulong>(); for (var i = 0; i < COUNT; ++i) { var id = manifest.AllocateIdentifier(); level.Add(id); } manifest.CommitLevel(Array.Empty <byte>(), l, level.ToArray()); } } // ReSharper disable once AccessToDisposedClosure Assert.ThrowsException <BadMagicException>(() => { var manifest = new Manifest(new DirectoryInfo("."), ms, new PlaneDBOptions().EnableEncryption("test")); manifest.Dispose(); }); }