Ejemplo n.º 1
0
 public void CheckDocumentCountIsZero()
 {
     using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
     {
         sp.DestroyExistingData();
     long count =  sp.Count();
     Assert.AreEqual (0, count);
     }
 }
Ejemplo n.º 2
0
 public void InitialiseStorageProcessor100Times()
 {
     using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
     {
         sp.DestroyExistingData();
         for (int i = 0; i < 100; i++) {
             sp.Initialise();
         }
     }
     Assert.IsTrue(true);
 }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
 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());
     }
 }
Ejemplo n.º 8
0
        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);
            }
        }
Ejemplo n.º 9
0
        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++;
                }
            }
        }
Ejemplo n.º 10
0
        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);

            }
        }
Ejemplo n.º 11
0
 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);
 }