예제 #1
0
        public void Adds_Document_With_Serial_PK()
        {
            var newCustomer = new ClientDocument {
                Email     = "*****@*****.**",
                FirstName = "Rob",
                LastName  = "Conery"
            };

            IBiggyStore <ClientDocument> docStore = clientDocs as IBiggyStore <ClientDocument>;

            docStore.Add(newCustomer);
            docStore.Load();
            Assert.Equal(1, docStore.Load().Count());
        }
예제 #2
0
 public BiggyList(IBiggyStore <T> store)
 {
     _store                = store;
     _queryableStore       = _store as IQueryableBiggyStore <T>;
     _updateableBiggyStore = _store as IUpdateableBiggyStore <T>;
     _items                = _store.Load();
 }
예제 #3
0
        public void Removes_Range_From_Store()
        {
            _biggyWidgetList.Clear();

            int INSERT_QTY = 100;
            var batch      = new List <Widget>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                batch.Add(new Widget {
                    SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = 2.00M + i
                });
            }
            _biggyWidgetList.Add(batch);
            _biggyWidgetList = new BiggyList <Widget>(_widgets);

            // Grab a range of items to remove:
            var itemsToRemove = _widgets.Load().Where(w => w.Price > 5 && w.Price <= 20);
            int removedQty    = itemsToRemove.Count();

            _biggyWidgetList.Remove(itemsToRemove.ToList());

            // Reload again, just to be sure:
            _biggyWidgetList = new BiggyList <Widget>(_widgets);
            Assert.True(removedQty > 0 && removedQty < INSERT_QTY && _biggyWidgetList.Count() == (INSERT_QTY - removedQty));
        }
예제 #4
0
        public List <T> Load()
        {
            List <T> items = _biggyStore.Load();

            _luceneIndexer.DeleteAll();
            _luceneIndexer.AddDocumentsToIndex(items);
            return(items);
        }
예제 #5
0
파일: BiggyList.cs 프로젝트: grufffta/biggy
 public BiggyList(IBiggyStore <T> store, bool inMemory = false)
 {
     _store           = store;
     _queryableStore  = _store as IQueryableBiggyStore <T>;
     _updateableStore = _store as IUpdateableBiggyStore <T>;
     _items           = _store.Load();
     this.InMemory    = inMemory;
 }
예제 #6
0
        public void Adds_Item_To_Store()
        {
            _widgets.Clear();
            _widgets.Add(new Widget {
                SKU = "001", Name = "Test widget 1", Price = 2.00M
            });
            var itemsInStore = _widgets.Load();

            Assert.True(itemsInStore.Count() > 0);
        }
예제 #7
0
        public void Inserts_Record_With_Composite_PK()
        {
            var newBuilding = new Building {
                PropertyId = 1, BuildingId = 1, Name = "Building A"
            };

            _buildingStore.Add(newBuilding);

            var fetchBuilding = _buildingStore.Load().First();

            Assert.True(fetchBuilding.PropertyId == 1 && fetchBuilding.BuildingId == 1 && fetchBuilding.Name == "Building A");
        }
예제 #8
0
 public BiggyList(bool inMemory = false)
 {
     // Unless the in-memory flag is set, initialize with JSON store:
     if (!inMemory)
     {
         _store = new JSON.JsonStore <T>();
     }
     _items        = (_store != null) ? _store.Load() : new List <T>();
     this.InMemory = inMemory;
 }
예제 #9
0
        public void IUpdateableBiggyStore_Deletes_Many_Records()
        {
            _biggyStore = new SqlCeStore <Client>(_connectionStringName);
            var insertThese = new List <Client>();

            for (int i = 0; i < 10; i++)
            {
                var newClient = new Client()
                {
                    LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**"
                };
                insertThese.Add(newClient);
            }
            _biggyStore.Add(insertThese);
            var newClients = _biggyStore.Load();

            _biggyStore.Remove(newClients);
            newClients = _biggyStore.Load();
            Assert.True(newClients.Count == 0);
        }
예제 #10
0
        public void IUpdateableBiggyStore_Deletes_Record()
        {
            _biggyStore = new SqlCeStore <Client>(_connectionStringName);
            var newClient = new Client()
            {
                LastName = "Atten", FirstName = "John", Email = "*****@*****.**"
            };

            _biggyStore.Add(newClient);

            // Stow the id so we can reload, then update (just to be SURE!!)
            int idToFind = newClient.ClientId;

            newClient = _biggyStore.Load().FirstOrDefault(c => c.ClientId == idToFind);

            var deleteMe = _biggyStore.Load().FirstOrDefault(c => c.ClientId == idToFind);

            _biggyStore.Remove(deleteMe);
            var clients = _biggyStore.Load();

            Assert.True(clients.Count == 0);
        }
예제 #11
0
        public void IUpdateableBiggyStore_Updates_Record()
        {
            _biggyStore = new SqlCeStore <Client>(_connectionStringName);
            var newClient = new Client()
            {
                LastName = "Atten", FirstName = "John", Email = "*****@*****.**"
            };

            _biggyStore.Add(newClient);

            // Stow the id so we can reload, then update (just to be SURE!!)
            int idToFind = newClient.ClientId;

            newClient           = _biggyStore.Load().FirstOrDefault(c => c.ClientId == idToFind);
            newClient.FirstName = "John Paul";
            newClient.LastName  = "Jones";
            _biggyStore.Update(newClient);

            var updatedClient = _biggyStore.Load().FirstOrDefault(c => c.ClientId == idToFind);

            Assert.True(updatedClient.LastName == "Jones");
        }
예제 #12
0
        public void IBiggyStore_Adds_Many_Records()
        {
            _biggyStore = new PGStore<Client>(_connectionStringName);
              var insertThese = new List<Client>();

              for (int i = 0; i < 10; i++) {
            var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" };
            insertThese.Add(newClient);
              }
              _biggyStore.Add(insertThese);
              var newClients = _biggyStore.Load();
              Assert.True(newClients.Count > 0);
        }
예제 #13
0
        public void Clears_List_But_Not_Store()
        {
            _biggyMemoryList = new BiggyList <Widget>(_widgetStore, inMemory: true);
            _biggyMemoryList.Clear();
            var storeWidgets = _widgetStore.Load();

            Assert.True(_biggyMemoryList.Count() == 0 && storeWidgets.Count == INSERT_QTY);
        }
예제 #14
0
        public void IBiggyDocumentStore_Add_A_Lot_Of_Records()
        {
            _clientDocs = new SqlCeDocumentStore <ClientDocument>(_connectionStringName);
            int recordsCnt = 500;
            List <ClientDocument> clients = new List <ClientDocument>(500);

            foreach (var i in Enumerable.Range(0, recordsCnt))
            {
                clients.Add(new ClientDocument {
                    Email     = "client" + i + "@domain.com",
                    FirstName = "client#" + i,
                    LastName  = "last#" + i
                });
            }

            var result = _clientDocs.Add(clients);

            // check for Pks
            Assert.Equal(recordsCnt, result.Last().ClientDocumentId);

            var newList = _clientDocs.Load();

            Assert.Equal(recordsCnt, newList.Count);
        }
예제 #15
0
 public void Creates_Document_Table_With_Composite_PK_If_Not_Present()
 {
     Assert.True(buildingDocs.Load().Count() == 0);
 }
예제 #16
0
 public bool LoadItems()
 {
     _items = _store.Load();
     return(true);
 }
예제 #17
0
 public BiggyList(IBiggyStore <T> store, bool inMemory = false)
 {
     _store        = store;
     _items        = (_store != null) ? _store.Load() : new List <T>();
     this.InMemory = inMemory;
 }
예제 #18
0
 public void Creates_Document_Table_With_String_PK_If_Not_Present()
 {
     Assert.True(monkeyDocs.Load().Count() == 0);
 }
예제 #19
0
 public void Creates_Document_Table_With_Serial_PK_If_Not_Present()
 {
     Assert.True(clientDocs.Load().Count() == 0);
 }
예제 #20
0
        public void IUpdateableBiggyStore_Updates_Record()
        {
            _biggyStore = new PGStore<Client>(_connectionStringName);
              var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
              _biggyStore.Add(newClient);

              // Stow the id so we can reload, then update (just to be SURE!!)
              int idToFind = newClient.ClientId;
              newClient = _biggyStore.Load().FirstOrDefault(c => c.ClientId == idToFind);
              newClient.FirstName = "John Paul";
              newClient.LastName = "Jones";
              _biggyStore.Update(newClient);

              var updatedClient = _biggyStore.Load().FirstOrDefault(c => c.ClientId == idToFind);
              Assert.True(updatedClient.LastName == "Jones");
        }
예제 #21
0
        public void IUpdateableBiggyStore_Deletes_Record()
        {
            _biggyStore = new PGStore<Client>(_connectionStringName);
              var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
              _biggyStore.Add(newClient);

              // Stow the id so we can reload, then update (just to be SURE!!)
              int idToFind = newClient.ClientId;
              newClient = _biggyStore.Load().FirstOrDefault(c => c.ClientId == idToFind);

              var deleteMe = _biggyStore.Load().FirstOrDefault(c => c.ClientId == idToFind);
              _biggyStore.Remove(deleteMe);
              var clients = _biggyStore.Load();
              Assert.True(clients.Count == 0);
        }
예제 #22
0
        public void IBiggyStore_Add_A_Lot_Of_Records()
        {
            _biggyStore = new SqlCeStore<Client>(_connectionStringName);
              int recordsCnt = 500;
              List<Client> clients = new List<Client>(500);
              foreach (var i in Enumerable.Range(0, recordsCnt)) {
            clients.Add(new Client {
              Email = "client" + i + "@domain.com",
              FirstName = "client#" + i,
              LastName = "last#" + i
            });
              }

              var result = _biggyStore.Add(clients);
              // check for Pks
              Assert.Equal(recordsCnt, result.Last().ClientId);

              var newList = _biggyStore.Load();
              Assert.Equal(recordsCnt, newList.Count);
        }