public void Biggylist_Updates_Single_Item_In_Sqlite_Store() { var PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); int initialCount = PropertyDocumentList.Count; var newPropertyDocument = new PropertyDocument { Name = "John's Luxury Apartments", Address = "2639 I St NW, Washington, D.C. 20037" }; PropertyDocumentList.Add(newPropertyDocument); int addedItemId = newPropertyDocument.Id; // Just to be sure, reload from backing store and check what was added: PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); var addedPropertyDocument = PropertyDocumentList.FirstOrDefault(p => p.Id == addedItemId); bool isAddedProperly = addedPropertyDocument.Name.Contains("John's Luxury"); // Now Update: string newName = "John's Low-Rent Apartments"; addedPropertyDocument.Name = newName; PropertyDocumentList.Update(addedPropertyDocument); // Go fetch again: PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); addedPropertyDocument = PropertyDocumentList.FirstOrDefault(p => p.Id == addedItemId); bool isUpdatedProperly = addedPropertyDocument.Name == newName; Assert.IsTrue(isAddedProperly && isUpdatedProperly); }
public void Biggylist_Updates_Single_Item_In_Sqlite_Store() { var PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); int initialCount = PropertyDocumentList.Count; var newPropertyDocument = new PropertyDocument { Name = "John's Luxury Apartments", Address = "2639 I St NW, Washington, D.C. 20037" }; PropertyDocumentList.Add(newPropertyDocument); int addedItemId = newPropertyDocument.Id; // Just to be sure, reload from backing store and check what was added: PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); var addedPropertyDocument = PropertyDocumentList.FirstOrDefault(p => p.Id == addedItemId); bool isAddedProperly = addedPropertyDocument.Name.Contains("John's Luxury"); // Now Update: string newName = "John's Low-Rent Apartments"; addedPropertyDocument.Name = newName; PropertyDocumentList.Update(addedPropertyDocument); // Go fetch again: PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); addedPropertyDocument = PropertyDocumentList.FirstOrDefault(p => p.Id == addedItemId); bool isUpdatedProperly = addedPropertyDocument.Name == newName; Assert.IsTrue(isAddedProperly && isUpdatedProperly); }
public void Biggylist_Removes_Single_Item_From_Sqlite_Store() { var PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); int initialCount = PropertyDocumentList.Count; var newPropertyDocument = new PropertyDocument { Name = "John's High-End Apartments", Address = "16 PropertyDocument Parkway, Portland, OR 97204" }; PropertyDocumentList.Add(newPropertyDocument); int addedItemId = newPropertyDocument.Id; // Just to be sure, reload from backing store and check what was added: PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); var addedPropertyDocument = PropertyDocumentList.FirstOrDefault(p => p.Id == addedItemId); bool isAddedProperly = addedPropertyDocument.Name.Contains("High-End"); int qtyAdded = PropertyDocumentList.Count; // Delete: var foundPropertyDocument = PropertyDocumentList.FirstOrDefault(); PropertyDocumentList.Remove(foundPropertyDocument); PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); int remaining = PropertyDocumentList.Count; Assert.IsTrue(isAddedProperly && qtyAdded == 1 && remaining == 0); }
public void Biggylist_Adds_Single_Item_To_Sqlite_Store() { var PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); int initialCount = PropertyDocumentList.Count; var newPropertyDocument = new PropertyDocument { Name = "Watergate Apartments", Address = "2639 I St NW, Washington, D.C. 20037" }; PropertyDocumentList.Add(newPropertyDocument); // Reload from the store: PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); var addedItems = PropertyDocumentList.FirstOrDefault(p => p.Name.Contains("Watergate")); Assert.IsTrue(initialCount == 0 && PropertyDocumentList.Count == 1 && addedItems.Id == 1); }
public void Biggylist_Adds_Range_Of_Items_To_Sqlite_Store() { var PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); int initialCount = PropertyDocumentList.Count; var myBatch = new List<PropertyDocument>(); int qtyToAdd = 10; for (int i = 1; i <= qtyToAdd; i++) { var newPropertyDocument = new PropertyDocument { Name = "New Apartment " + i, Address = "Some Street in a Lonely Town" }; myBatch.Add(newPropertyDocument); } PropertyDocumentList.Add(myBatch); // Reload from the store: PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); var addedItems = PropertyDocumentList.Where(p => p.Id > 0); Assert.IsTrue(initialCount == 0 && addedItems.Count() > 0); }
public void Biggylist_Adds_Single_Item_To_Sqlite_Store() { var PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); int initialCount = PropertyDocumentList.Count; var newPropertyDocument = new PropertyDocument { Name = "Watergate Apartments", Address = "2639 I St NW, Washington, D.C. 20037" }; PropertyDocumentList.Add(newPropertyDocument); // Reload from the store: PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); var addedItems = PropertyDocumentList.FirstOrDefault(p => p.Name.Contains("Watergate")); Assert.IsTrue(initialCount == 0 && PropertyDocumentList.Count == 1 && addedItems.Id == 1); }
public void Biggylist_Adds_Range_Of_Items_To_Sqlite_Store() { var PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); int initialCount = PropertyDocumentList.Count; var myBatch = new List <PropertyDocument>(); int qtyToAdd = 10; for (int i = 1; i <= qtyToAdd; i++) { var newPropertyDocument = new PropertyDocument { Name = "New Apartment " + i, Address = "Some Street in a Lonely Town" }; myBatch.Add(newPropertyDocument); } PropertyDocumentList.Add(myBatch); // Reload from the store: PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); var addedItems = PropertyDocumentList.Where(p => p.Id > 0); Assert.IsTrue(initialCount == 0 && addedItems.Count() > 0); }
public void Biggylist_Removes_Single_Item_From_Sqlite_Store() { var PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); int initialCount = PropertyDocumentList.Count; var newPropertyDocument = new PropertyDocument { Name = "John's High-End Apartments", Address = "16 PropertyDocument Parkway, Portland, OR 97204" }; PropertyDocumentList.Add(newPropertyDocument); int addedItemId = newPropertyDocument.Id; // Just to be sure, reload from backing store and check what was added: PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); var addedPropertyDocument = PropertyDocumentList.FirstOrDefault(p => p.Id == addedItemId); bool isAddedProperly = addedPropertyDocument.Name.Contains("High-End"); int qtyAdded = PropertyDocumentList.Count; // Delete: var foundPropertyDocument = PropertyDocumentList.FirstOrDefault(); PropertyDocumentList.Remove(foundPropertyDocument); PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); int remaining = PropertyDocumentList.Count; Assert.IsTrue(isAddedProperly && qtyAdded == 1 && remaining == 0); }