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 void Removes_Many_Items_From_List_And_Store() { int INSERT_QTY = 10; // Just in case: _clients.Clear(); var addThese = new List <Client>(); for (int i = 0; i < INSERT_QTY; i++) { var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" }; addThese.Add(newClient); } _clients.Add(addThese); // Open a new instance, to see if the item was added to the backing store as well: var altClientArray = new BiggyList <Client>(new PGStore <Client>(_connectionStringName)).ToArray(); var removeThese = new List <Client>(); for (int i = 0; i < 5; i++) { removeThese.Add(altClientArray[i]); } _clients.Remove(removeThese); // Reload the list: _clients = new BiggyList <Client>(new PGStore <Client>(_connectionStringName)); Assert.True(_clients.Count() == (INSERT_QTY - removeThese.Count())); }
public void Removes_Item_From_List_But_Not_Store() { _biggyMemoryList = new BiggyList <Widget>(_widgetStore, inMemory: true); var removeMe = _biggyMemoryList.FirstOrDefault(); _biggyMemoryList.Remove(removeMe); var storeWidgets = _widgetStore.Load(); Assert.True(_biggyMemoryList.Count() == INSERT_QTY - 1 && storeWidgets.Count == INSERT_QTY); }
public void Removes_Range_From_List_But_Not_Store() { _biggyMemoryList = new BiggyList <Widget>(_widgetStore, inMemory: true); // Grab a range of items to remove: var itemsToRemove = _biggyMemoryList.Where(w => w.Price > 5 && w.Price <= 20); int removedQty = itemsToRemove.Count(); _biggyMemoryList.Remove(itemsToRemove.ToList()); var storeWidgets = _widgetStore.Load(); Assert.True(_biggyMemoryList.Count() < storeWidgets.Count()); }
public void Removes_Item_From_List_And_Store() { _biggyWidgetList.Clear(); _biggyWidgetList.Add(new Widget { SKU = "001", Name = "Test widget 1", Price = 2.00M }); // Reload: _biggyWidgetList = new BiggyList <Widget>(_widgets); var removeMe = _biggyWidgetList.FirstOrDefault(); _biggyWidgetList.Remove(removeMe); _biggyWidgetList = new BiggyList <Widget>(_widgets); Assert.True(_biggyWidgetList.Count() == 0); }
public void Deletes_Document_With_Serial_PK() { var newCustomer = new ClientDocument { Email = "*****@*****.**", FirstName = "Rob", LastName = "Conery" }; _clientDocuments.Add(newCustomer); // Count after adding new: int initialCount = _clientDocuments.Count(); var removed = _clientDocuments.Remove(newCustomer); // Reload, make sure everything was persisted: _clientDocuments = new BiggyList <ClientDocument>(new PGDocumentStore <ClientDocument>(_connectionStringName)); // Count after removing and reloading: int finalCount = _clientDocuments.Count(); Assert.True(finalCount < initialCount); }
public void Removes_Range_From_List_But_Not_Store() { _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true); // Grab a range of items to remove: var itemsToRemove = _biggyMemoryList.Where(w => w.Price > 5 && w.Price <= 20); int removedQty = itemsToRemove.Count(); _biggyMemoryList.Remove(itemsToRemove.ToList()); var storeWidgets = _widgetStore.Load(); Assert.True(_biggyMemoryList.Count() < storeWidgets.Count()); }
public void Removes_Item_From_List_But_Not_Store() { _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true); var removeMe = _biggyMemoryList.FirstOrDefault(); _biggyMemoryList.Remove(removeMe); var storeWidgets = _widgetStore.Load(); Assert.True(_biggyMemoryList.Count() == INSERT_QTY -1 && storeWidgets.Count == INSERT_QTY); }
public void Removes_Item_From_List_And_Store() { _biggyWidgetList.Clear(); _biggyWidgetList.Add(new Widget { SKU = "001", Name = "Test widget 1", Price = 2.00M }); // Reload: _biggyWidgetList = new BiggyList<Widget>(_widgets); var removeMe = _biggyWidgetList.FirstOrDefault(); _biggyWidgetList.Remove(removeMe); _biggyWidgetList = new BiggyList<Widget>(_widgets); Assert.True(_biggyWidgetList.Count() == 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)); }