public void CanUpdate() { // Arrange var db = new MemoryDatabase(); var productToInsert1 = new Product(); db.Insert<Product>(productToInsert1); var productToInsert2 = new Product(); db.Insert<Product>(productToInsert2); var productToInsert3 = new Product(); db.Insert<Product>(productToInsert3); // Get original var originalProduct = db.Select<Product>().Where(p=>p.Id == 2).Select(p => p).FirstOrDefault(); // Create modified var modifiedProduct = new Product(); modifiedProduct.Name = "Modified"; // Update db.Update<Product>(originalProduct, modifiedProduct); // Get original originalProduct = db.Select<Product>().Where(p => p.Id == 2).Select(p => p).FirstOrDefault(); // Assert Assert.AreEqual("Modified", originalProduct.Name); }
public void AfterFirstInsertIdIs1() { // Arrange var db = new MemoryDatabase(); var productToInsert = new Product(); // Act db.Insert<Product>(productToInsert); // Assert Assert.AreEqual(1, productToInsert.Id); }
public void CanDelete() { // Arrange var db = new MemoryDatabase(); var productToInsert1 = new Product(); db.Insert<Product>(productToInsert1); var productToInsert2 = new Product(); db.Insert<Product>(productToInsert2); var productToInsert3 = new Product(); db.Insert<Product>(productToInsert3); // Act db.Delete<Product>(productToInsert2); // Assert Assert.AreEqual(2, db.Select<Product>().Count()); }
public void InsertFirstListFirst() { // Arrange var db = new MemoryDatabase(); // Act var productToInsert1 = new Product(); db.Insert<Product>(productToInsert1); var productToInsert2 = new Product(); db.Insert<Product>(productToInsert2); var productToInsert3 = new Product(); db.Insert<Product>(productToInsert3); // Assert var firstProduct = db.Select<Product>().FirstOrDefault(); Assert.AreEqual(1, firstProduct.Id); }
public void InsertIncrementsId() { // Arrange var db = new MemoryDatabase(); // Act var productToInsert1 = new Product(); db.Insert<Product>(productToInsert1); var productToInsert2 = new Product(); db.Insert<Product>(productToInsert2); var productToInsert3 = new Product(); db.Insert<Product>(productToInsert3); // Assert Assert.AreEqual(1, productToInsert1.Id); Assert.AreEqual(2, productToInsert2.Id); Assert.AreEqual(3, productToInsert3.Id); }