Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
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++;
                }
            }
        }