public void AfmLoadsJObjectsObjects() { _testName = MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString(); var formatter = TestResourceFactory.CreateJsonFormatterWithoutArrayFormatting(); var core = new FileCore<int, long>() { IdSeed = new Seed32(999), SegmentSeed = new Seed64(), MinimumCoreStride = 512 }; var entity = TestResourceFactory.CreateRandom() as MockClassC; long seg = -1; using (var fLock = new ManagedFileLock(_testName)) { Cleanup(); using (var afm = new AtomicFileManager<MockClassA>(_testName + ".database", core)) { afm.Load<int>(); entity.Id = core.IdSeed.Increment(); afm.Rebuilt += new Rebuild<MockClassA>(delegate(Guid transactionId, int newStride, long newLength, int newSeedStride) { afm.SaveCore<int>(); }); seg = AtomicFileManagerHelper.SaveSegment(afm, entity, entity.Id); afm.SaveCore<int>(); } using (var afm = new AtomicFileManager<MockClassA>(_testName + ".database")) { afm.Load<int>(); Assert.AreEqual(512, afm.Stride); Assert.AreEqual(1024, afm.CorePosition); var obj = afm.LoadJObjectFrom(seg); Assert.IsNotNull(obj); Assert.AreEqual(entity.Id, obj.Value<int>("Id")); Assert.AreEqual(entity.Name, obj.Value<string>("Name")); Assert.AreEqual(entity.GetSomeCheckSum, obj.GetAsTypedArray<double>("GetSomeCheckSum")); Assert.AreEqual(entity.Location.X, obj.SelectToken("Location.X").Value<float>()); Assert.AreEqual(entity.Location.Y, obj.SelectToken("Location.Y").Value<float>()); Assert.AreEqual(entity.Location.Z, obj.SelectToken("Location.Z").Value<float>()); Assert.AreEqual(entity.Location.W, obj.SelectToken("Location.W").Value<float>()); Assert.AreEqual(entity.ReferenceCode, obj.Value<string>("ReferenceCode")); Assert.AreEqual(entity.ReplicationID, obj.Value<Guid>("ReplicationID")); } } }