public void StoreThreeDocumentsLoadFirstDocument() { using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer)) { sp.DestroyExistingData(); var person = new PersonEntity() { Name = "Test 2", Email = "Test 2" }; sp.Store<PersonEntity>(person); sp.Store<PersonEntity>(new PersonEntity() { Name = "Test 1", Email = "Test 1" }); var loadPerson = sp.Load<PersonEntity>(person.Id); Assert.AreEqual (person.Id, loadPerson.Id); } }
public void Inser100DocumentsDelete100DocumentsInsert100CheckFileSizeIsSameAsAfterDelete() { using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer)) { sp.DestroyExistingData(); for (int i = 1; i < 101; i++) { sp.Store<PersonEntity>(new PersonEntity() { Id = i, Name = "Test", Email = "Test" }); #if DEBUG Console.WriteLine("File Size: " + sp.FileSize); #endif } // store file size for the assert long fileSize = sp.FileSize; for (int i = 1; i < 101; i++) { sp.Delete(i); #if DEBUG Console.WriteLine("File Size: " + sp.FileSize); #endif } Assert.AreEqual(fileSize, sp.FileSize); // store another documet file size should be the same. for (int i = 1; i < 101; i++) { sp.Store<PersonEntity>(new PersonEntity() { Id = i, Name = "Test", Email = "Test" }); #if DEBUG Console.WriteLine("File Size: " + sp.FileSize); #endif } Assert.AreEqual(fileSize, sp.FileSize); } }
public void InsertOneDocumentUpdateDocumentSoRelocatedInsertNewDocumentWithSameSizeCheckFileSizeIsSame() { using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer)) { sp.DestroyExistingData(); // insert one record and get file size var entity = new PersonEntity() { Name = "Test", Email = "Test" }; var entity2 = new PersonEntity() { Name = "Test", Email = "Test" }; sp.Store<PersonEntity>(entity); // store file size for the assert entity.Name = "1000000hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"; sp.Update<PersonEntity>(entity); var fileSize = sp.FileSize; Assert.AreEqual(fileSize, sp.FileSize); // store another documet file size should be the same. sp.Store<PersonEntity>(entity2); Assert.AreEqual(fileSize, sp.FileSize); } }
public void StoreThreeDocumentsDeleteOneDocumentLoadDeletedDocumentReturnsNull() { using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer)) { sp.DestroyExistingData(); var person = new PersonEntity() { Name = "Test 2", Email = "Test 2" }; sp.Store<PersonEntity>(person); sp.Store<PersonEntity>(new PersonEntity() { Name = "Test 1", Email = "Test 1" }); sp.Delete(person.Id); var loadPerson = sp.Load<PersonEntity>(person.Id); Assert.IsNull(loadPerson); } }
public void Insert1RecordsCheckCount1RemoveCheckDocumentCountIs0() { using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer)) { sp.DestroyExistingData(); var person = new PersonEntity() { Name = "Person " + 1, Email = "Email " + 1 }; sp.Store<PersonEntity>(person); Assert.AreEqual(1, sp.Count()); sp.Delete(person.Id); Assert.AreEqual (0, sp.Count()); } }
public void Insert1RecordChangeDataAndUpdateCheckUpdated() { using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer)) { sp.DestroyExistingData(); var person = new PersonEntity() { Name = "Person", Email = "Email" }; sp.Store<PersonEntity>(person); Assert.AreEqual(1, sp.Count()); var existingPerson = sp.Load<PersonEntity>(person.Id); existingPerson.Name = "Person With Longer Name"; sp.Update<PersonEntity>(existingPerson); Assert.AreEqual(1, sp.Count()); // check updated var updatedPerson = sp.Load<PersonEntity>(person.Id); Assert.AreEqual ("Person With Longer Name", updatedPerson.Name); } }
public void Insert100RecordsLoad100CheckAllMatchInserted() { using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer)) { sp.DestroyExistingData(); for (int i = 1; i < 101; i++) { sp.Store<PersonEntity>(new PersonEntity() { Name = "Person " + i, Email = "Email " + i }); #if DEBUG Console.WriteLine("INSERT: {0}", i); #endif } long count = sp.Count(); Assert.AreEqual (100, count); // load var records = sp.Load<PersonEntity>(); int countCheck = 1; foreach(var r in records){ Assert.AreEqual(r.Name, "Person " + countCheck); Assert.AreEqual(r.Email, "Email " + countCheck); countCheck++; } } }
public void Insert100DocumentsCheckDocumentCountIs100() { using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer)) { sp.DestroyExistingData(); for (int i = 1; i < 101; i++) { sp.Store<PersonEntity>(new PersonEntity() { Name = "Person " + i, Email = "Email " + i }); #if DEBUG Console.WriteLine("INSERT: {0}", i); #endif } long count = sp.Count(); Assert.AreEqual (100, count); } }
public void Insert10000Documents() { using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer)) { sp.DestroyExistingData(); for (int i = 1; i < 10001; i++) { sp.Store<PersonEntity>(new PersonEntity() { Name = "Person " + i, Email = "Email " + i }); #if DEBUG Console.WriteLine("INSERT: {0}", i); #endif } } Assert.True (true); }