Example #1
0
        public void EnsurePersistenceTest()
        {
            var numberOfSectorTesting = 5;

            _store.Initialize();
            // manually make a sector
            var sector = new Sector(_sectorSize);

            var contentBytes = new byte[sector.Contents.Length];

            for (var i = 0; i < numberOfSectorTesting; i++)
            {
                _rnd.NextBytes(contentBytes);
                contentBytes.AsSpan().CopyTo(sector.Contents);

                var index = _store.AllocateSectors(4);
                _store.Write(index, sector);
            }

            _store.EnsurePersistence();
            _store.Dispose();

            // reinit store
            _store = _storeFixiture.Create();

            _store.Initialize();
            var sectorIndex   = new SectorIndex((numberOfSectorTesting - 1) * 4);
            var storeProvided = _store.Read(sectorIndex);

            Assert.True(storeProvided.Contents.SequenceEqual(contentBytes.AsSpan()));
        }
Example #2
0
        public void StoreWriteRead()
        {
            SectorIndex index = new SectorIndex(3);

            _store.Initialize();
            // manually make a sector
            var sector = new Sector(_sectorSize);

            var rnd          = new Random(42);
            var contentBytes = new byte[sector.Contents.Length];

            rnd.NextBytes(contentBytes);
            contentBytes.AsSpan().CopyTo(sector.Contents);

            _store.AllocateSectors(4);
            _store.Write(index, sector);

            var storeProvided = _store.Read(index);

            Assert.True(storeProvided.Contents.SequenceEqual(contentBytes.AsSpan()));
        }