コード例 #1
0
        public void AtomicFileManagerReturnsPagedStream()
        {
            _testName = MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString();
            Cleanup();

            var formatter = new BSONFormatter();
            var core = new FileCore<int, long>() { IdSeed = new Seed32(999), SegmentSeed = new Seed64(), MinimumCoreStride = 512 };
            var addEntities = TestResourceFactory.GetMockClassAObjects(20480).ToList();

            foreach (var entity in addEntities)
                entity.Id = core.IdSeed.Increment();

            var updateEntities = new List<MockClassC>();

            IDictionary<int, long> returnSegments = null;
            IDictionary<int, long> deletedSegments = new Dictionary<int, long>();

            using (var afm = new AtomicFileManager<MockClassA>(_testName + ".database", core))
            {
                afm.Load<int>();

                afm.Rebuilt += new Rebuild<MockClassA>(delegate(Guid transactionId, int newStride, long newLength, int newSeedStride)
                {
                    afm.SaveCore<int>();
                });

                var segs = AtomicFileManagerHelper.SaveSegments(afm, addEntities.ToDictionary(e => e.Id));

                afm.SaveCore<int>();

                var s = afm.GetPageStream(1);

                Assert.IsNotNull(s);
                Assert.GreaterOrEqual(s.Length, 1441792);
                Assert.AreEqual(8, afm.AsStreaming().Count());
            }
        }