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()); }
public BiggyList(IBiggyStore <T> store) { _store = store; _queryableStore = _store as IQueryableBiggyStore <T>; _updateableBiggyStore = _store as IUpdateableBiggyStore <T>; _items = _store.Load(); }
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)); }
public List <T> Load() { List <T> items = _biggyStore.Load(); _luceneIndexer.DeleteAll(); _luceneIndexer.AddDocumentsToIndex(items); return(items); }
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; }
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); }
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"); }
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; }
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); }
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); }
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"); }
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); }
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); }
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); }
public void Creates_Document_Table_With_Composite_PK_If_Not_Present() { Assert.True(buildingDocs.Load().Count() == 0); }
public bool LoadItems() { _items = _store.Load(); return(true); }
public BiggyList(IBiggyStore <T> store, bool inMemory = false) { _store = store; _items = (_store != null) ? _store.Load() : new List <T>(); this.InMemory = inMemory; }
public void Creates_Document_Table_With_String_PK_If_Not_Present() { Assert.True(monkeyDocs.Load().Count() == 0); }
public void Creates_Document_Table_With_Serial_PK_If_Not_Present() { Assert.True(clientDocs.Load().Count() == 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"); }
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); }
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); }