public void Add_ValidCategory_ShouldCategoryIdBiggerThanNull() { var category = new Category { PictureUrl = "http://www.test.com/", Title = "Testss" }; this.dbContext.Set<Category>().Add(category); this.dbContext.SaveChanges(); Assert.IsTrue(category.Id > 0); }
public void Add_WhenCategoryIsValid_ShouldReturnNotZeroId() { int catId; using (TransactionScope scope = new TransactionScope()) { var category = new Category { PictureUrl = "http://www.test.com/", Title = "Testss" }; this.dbContext.Set<Category>().Add(category); this.dbContext.SaveChanges(); scope.Complete(); catId = category.Id; } Assert.IsTrue(catId != 0); var catEntity = this.dbContext.Set<Category>().Find(catId); Assert.IsNotNull(catEntity); }