Ejemplo n.º 1
0
        public void DB_EditModifiesDbItem_Product()
        {
            string  startName = "this is the product's old name";
            string  newName   = "this is the product's new name";
            Product product   = new Product {
                Name = startName, Description = "Its another test", Cost = 6
            };

            db.Save(product);

            product.Name = newName;
            db.Edit(product);

            Assert.AreEqual(newName, db.Products.FirstOrDefault(p => p.ProductId == product.ProductId).Name);
        }
        public void DB_EditUpdatesInDatabase_String()
        {
            // Arrange
            Product testProduct = new Product {
                ProductId = 1, Name = "Giant Gummi", Description = "12 oz. gummi bear", Cost = 4.99m, ImageUrl = "https://i.ytimg.com/vi/1CbfG0epWHo/maxresdefault.jpg"
            };

            db.Save(testProduct);

            //Act
            testProduct.Name = "Edited Test Product";
            db.Edit(testProduct);

            //Assert
            Assert.AreEqual("Edited Test Product", testProduct.Name);
        }