public void Initializes_Memory_Only_List_With_True_Argument() { _biggyMemoryList = new BiggyList <Widget>(inMemory: true); var BiggyJsonList = new BiggyList <Widget>(); _biggyMemoryList.Clear(); BiggyJsonList.Clear(); 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 = i }); } _biggyMemoryList.Add(batch); BiggyJsonList.Add(batch); int memoryCount = _biggyMemoryList.Count(); _biggyMemoryList.Clear(); BiggyJsonList = new BiggyList <Widget>(); Assert.True(memoryCount == INSERT_QTY && _biggyMemoryList.Count() == 0 && BiggyJsonList.Count() == INSERT_QTY); }
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 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 Clears_All_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); // Reload the list: _clients = new BiggyList <Client>(new PGStore <Client>(_connectionStringName)); int loadedCount = _clients.Count(); _clients.Clear(); // Reload the list: _clients = new BiggyList <Client>(new PGStore <Client>(_connectionStringName)); int clearedCount = _clients.Count(); Assert.True(loadedCount == INSERT_QTY && clearedCount == 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)); }
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 Adds_Item_To_List_But_Not_Store() { _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true); _biggyMemoryList.Add(new Widget { SKU = "1000", Name = "Test widget 1", Price = 2.00M }); var storeWidgets = _widgetStore.Load(); var addedItem = _biggyMemoryList.FirstOrDefault(w => w.SKU == "001"); Assert.True(addedItem != null && _biggyMemoryList.Count() == INSERT_QTY + 1 && storeWidgets.Count() == INSERT_QTY); }
public void Adds_Item_To_List_And_Store() { _biggyWidgetList.Clear(); _biggyWidgetList.Add(new Widget { SKU = "001", Name = "Test widget 1", Price = 2.00M }); // Reload the list: _biggyWidgetList = new BiggyList<Widget>(_widgets); var addedItem = _biggyWidgetList.FirstOrDefault(w => w.SKU == "001"); Assert.True(addedItem != null && _biggyWidgetList.Count() == 1); }
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 Adds_Item_To_List_But_Not_Store() { _biggyMemoryList = new BiggyList <Widget>(_widgetStore, inMemory: true); _biggyMemoryList.Add(new Widget { SKU = "1000", Name = "Test widget 1", Price = 2.00M }); var storeWidgets = _widgetStore.Load(); var addedItem = _biggyMemoryList.FirstOrDefault(w => w.SKU == "001"); Assert.True(addedItem != null && _biggyMemoryList.Count() == INSERT_QTY + 1 && storeWidgets.Count() == INSERT_QTY); }
public void Adds_Item_To_List_And_Store() { _biggyWidgetList.Clear(); _biggyWidgetList.Add(new Widget { SKU = "001", Name = "Test widget 1", Price = 2.00M }); // Reload the list: _biggyWidgetList = new BiggyList <Widget>(_widgets); var addedItem = _biggyWidgetList.FirstOrDefault(w => w.SKU == "001"); Assert.True(addedItem != null && _biggyWidgetList.Count() == 1); }
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 Adds_Batch_Of_Items_To_List_But_Not_Store() { _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true); int INSERT_QTY = 100; var batch = new List<Widget>(); for (int i = 0; i < INSERT_QTY; i++) { batch.Add(new Widget { SKU = string.Format("100{0}", i), Name = string.Format("Test widget {0}", i), Price = 2.00M }); } _biggyMemoryList.Add(batch); // Reload the List: var storeWidgets = _widgetStore.Load(); Assert.True(_biggyMemoryList.Count() == 2 * INSERT_QTY && storeWidgets.Count() == INSERT_QTY); }
public void Initializes_List_With_Json_Default_Store() { _biggyMemoryList = new BiggyList <Widget>(); _biggyMemoryList.Clear(); 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 = i }); } _biggyMemoryList.Add(batch); Assert.True(_biggyMemoryList.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 Bulk_Inserts_Documents_With_String_PK() { int INSERT_QTY = 100; var addRange = new List <MonkeyDocument>(); for (int i = 0; i < INSERT_QTY; i++) { addRange.Add(new MonkeyDocument { Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } var inserted = _monkeyDocuments.Add(addRange); // Reload, make sure everything was persisted: _monkeyDocuments = new BiggyList <MonkeyDocument>(new PGDocumentStore <MonkeyDocument>(_connectionStringName)); Assert.True(_monkeyDocuments.Count() == INSERT_QTY); }
public void Bulk_Inserts_Documents_With_Serial_PK() { int INSERT_QTY = 100; var bulkList = new List<ClientDocument>(); for (int i = 0; i < INSERT_QTY; i++) { var newClientDocument = new ClientDocument { FirstName = "ClientDocument " + i, LastName = "Test", Email = "*****@*****.**" }; bulkList.Add(newClientDocument); } _clientDocuments.Add(bulkList); // Reload, make sure everything was persisted: _clientDocuments = new BiggyList<ClientDocument>(new SqlCeDocumentStore<ClientDocument>(_connectionStringName)); var last = _clientDocuments.Last(); Assert.True(_clientDocuments.Count() == INSERT_QTY && last.ClientDocumentId >= INSERT_QTY); }
public void Adds_Batch_Of_Items_To_List_But_Not_Store() { _biggyMemoryList = new BiggyList <Widget>(_widgetStore, inMemory: true); int INSERT_QTY = 100; var batch = new List <Widget>(); for (int i = 0; i < INSERT_QTY; i++) { batch.Add(new Widget { SKU = string.Format("100{0}", i), Name = string.Format("Test widget {0}", i), Price = 2.00M }); } _biggyMemoryList.Add(batch); // Reload the List: var storeWidgets = _widgetStore.Load(); Assert.True(_biggyMemoryList.Count() == 2 * INSERT_QTY && storeWidgets.Count() == INSERT_QTY); }
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 Bulk_Inserts_Documents_With_Serial_PK() { int INSERT_QTY = 100; var bulkList = new List <ClientDocument>(); for (int i = 0; i < INSERT_QTY; i++) { var newClientDocument = new ClientDocument { FirstName = "ClientDocument " + i, LastName = "Test", Email = "*****@*****.**" }; bulkList.Add(newClientDocument); } _clientDocuments.Add(bulkList); // Reload, make sure everything was persisted: _clientDocuments = new BiggyList <ClientDocument>(new PGDocumentStore <ClientDocument>(_connectionStringName)); var last = _clientDocuments.Last(); Assert.True(_clientDocuments.Count() == INSERT_QTY && last.ClientDocumentId >= INSERT_QTY); }
public void Clears_List_and_Store() { int INSERT_QTY = 100; var addRange = new List <MonkeyDocument>(); for (int i = 0; i < INSERT_QTY; i++) { addRange.Add(new MonkeyDocument { Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } var inserted = _monkeyDocuments.Add(addRange); // Reload, make sure everything was persisted: _monkeyDocuments = new BiggyList <MonkeyDocument>(new SQLDocumentStore <MonkeyDocument>(_host)); _monkeyDocuments.Clear(); // Reload, make sure everything was persisted: _monkeyDocuments = new BiggyList <MonkeyDocument>(new SQLDocumentStore <MonkeyDocument>(_host)); Assert.True(_monkeyDocuments.Count() == 0); }
public void Creates_Document_Table_With_String_PK_If_Not_Present() { Assert.True(_monkeyDocuments.Count() == 0); }
public void Creates_Document_Table_With_Serial_PK_If_Not_Present() { Assert.True(_clientDocuments.Count() == 0); }
public void Loads_Empty_List() { Assert.True(_clients.Count() == 0); }
public void Initializes_Memory_Only_List_With_True_Argument() { _biggyMemoryList = new BiggyList<Widget>(inMemory: true); var BiggyJsonList = new BiggyList<Widget>(); _biggyMemoryList.Clear(); BiggyJsonList.Clear(); 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 = i }); } _biggyMemoryList.Add(batch); BiggyJsonList.Add(batch); int memoryCount = _biggyMemoryList.Count(); _biggyMemoryList.Clear(); BiggyJsonList = new BiggyList<Widget>(); Assert.True(memoryCount == INSERT_QTY && _biggyMemoryList.Count() == 0 && BiggyJsonList.Count() == INSERT_QTY); }
public void Clears_All_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); // Reload the list: _clients = new BiggyList<Client>(_clientStore); int loadedCount = _clients.Count(); _clients.Clear(); // Reload the list: _clients = new BiggyList<Client>(_clientStore); int clearedCount = _clients.Count(); Assert.True(loadedCount == INSERT_QTY && clearedCount == 0); }
public void Initializes_List_With_Json_Default_Store() { _biggyMemoryList = new BiggyList<Widget>(); _biggyMemoryList.Clear(); 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 = i }); } _biggyMemoryList.Add(batch); Assert.True(_biggyMemoryList.Count() == INSERT_QTY); }
public void Initializes_List() { _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true); Assert.True(_biggyMemoryList.Count() == INSERT_QTY); }
public void Initializes_List() { _biggyMemoryList = new BiggyList <Widget>(_widgetStore, inMemory: true); Assert.True(_biggyMemoryList.Count() == INSERT_QTY); }
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 SqlCeDocumentStore<ClientDocument>(_connectionStringName)); // Count after removing and reloading: int finalCount = _clientDocuments.Count(); Assert.True(finalCount < initialCount); }
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_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>(_clientStore).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>(_clientStore); Assert.True(_clients.Count() == (INSERT_QTY - removeThese.Count())); }
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_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 Clears_List_and_Store() { int INSERT_QTY = 100; var addRange = new List<MonkeyDocument>(); for (int i = 0; i < INSERT_QTY; i++) { addRange.Add(new MonkeyDocument { Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } var inserted = _monkeyDocuments.Add(addRange); // Reload, make sure everything was persisted: _monkeyDocuments = new BiggyList<MonkeyDocument>(new SqlCeDocumentStore<MonkeyDocument>(_connectionStringName)); _monkeyDocuments.Clear(); // Reload, make sure everything was persisted: _monkeyDocuments = new BiggyList<MonkeyDocument>(new SqlCeDocumentStore<MonkeyDocument>(_connectionStringName)); Assert.True(_monkeyDocuments.Count() == 0); }
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 Bulk_Inserts_Documents_With_String_PK() { int INSERT_QTY = 100; var addRange = new List<MonkeyDocument>(); for (int i = 0; i < INSERT_QTY; i++) { addRange.Add(new MonkeyDocument { Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } var inserted = _monkeyDocuments.Add(addRange); // Reload, make sure everything was persisted: _monkeyDocuments = new BiggyList<MonkeyDocument>(new SQLDocumentStore<MonkeyDocument>(_host)); Assert.True(_monkeyDocuments.Count() == INSERT_QTY); }