public void ShouldUpdateCategoryName() { var cat = Db.Categories.First(); cat.CategoryName = "Bar"; Db.SaveChanges(); var updatedCat = new IntroToEfContext().Categories.First(); Assert.Equal("Bar", updatedCat.CategoryName); }
public void ShouldProductModelName() { var cat = Db.Categories.Include(c => c.Products).First(); var modelName = "Foo"; cat.Products.ToList()[0].ModelName = modelName; Db.SaveChanges(); var cat2 = new IntroToEfContext().Categories.Include(c => c.Products).First(); Assert.Equal(modelName, cat.Products.ToList()[0].ModelName); }
static void Main(string[] args) { using (var db = new IntroToEfContext()) { foreach (var item in db.Pet_Breed) { Console.WriteLine(item.BreedName); } } Console.ReadKey(); }
public void ShouldDeleteCategoryById() { var catCount = Db.Categories.Count(); var prodCount = Db.Products.Count(); var cat = Db.Categories.First(); var newDb = new IntroToEfContext(); var catToDelete = new Category { Id = cat.Id, TimeStamp = cat.TimeStamp }; newDb.Entry(catToDelete).State = EntityState.Deleted; newDb.SaveChanges(); Assert.Equal(catCount - 1, Db.Categories.Count()); Assert.Equal(prodCount - 2, Db.Products.Count()); }
public BaseTest() { Db = new IntroToEfContext(); }
public static void AddProduct(IntroToEfContext db, int categoryId, decimal price, string description, string modelName, string modelNumber, decimal unitCost, int quantity) { db.Database.ExecuteSqlCommand($"INSERT INTO [Store].[Products] ([CategoryId],[CurrentPrice],[Description],[IsFeatured],[ModelName],[ModelNumber],[UnitCost],[UnitsInStock]) VALUES ({categoryId}, {price}, '{description}',0,'{modelName}', '{modelNumber}', {unitCost}, {quantity})"); }
public static void AddCategory(IntroToEfContext db, string categoryName) { db.Database.ExecuteSqlCommand($"INSERT INTO [Store].[Categories] ([CategoryName]) VALUES ('{categoryName}')"); }
public ConcurrencyTests() { _db = new IntroToEfContext(); }
public UpdateDataTests() { _db = new IntroToEfContext(); }