public void ClearTableTest() { // setup var db = new OrmTestSession(); db.CreateTable <Product>(); // insert db.Insert(new Product { Name = "Hello", Price = 16, }); db.Insert(new Product { Name = "Hello", Price = 16, }); // confirm Assert.AreEqual(2, db.Table <Product>().Count()); db.Get <Product>(1); // clear Assert.AreEqual(2, db.ClearTable <Product>()); // confirm Assert.AreEqual(0, db.Table <Product>().Count()); // insert db.Insert(new Product { Name = "Hello", Price = 16, }); // confirm that the Ids have not reset Assert.AreEqual(1, db.Table <Product>().Count()); db.Get <Product>(3); }
public void ClearTableTest() { // setup var db = new OrmTestSession(); db.CreateTable<Product>(); // insert db.Insert(new Product { Name = "Hello", Price = 16, }); db.Insert(new Product { Name = "Hello", Price = 16, }); // confirm Assert.AreEqual(2, db.Table<Product>().Count()); db.Get<Product>(1); // clear Assert.AreEqual(2, db.ClearTable<Product>()); // confirm Assert.AreEqual(0, db.Table<Product>().Count()); // insert db.Insert(new Product { Name = "Hello", Price = 16, }); // confirm that the Ids have not reset Assert.AreEqual(1, db.Table<Product>().Count()); db.Get<Product>(3); }
public void FirstOrDefaultTest() { OrmTestSession db = CreateDb(); db.Insert(new Product { Name = "A", Price = 20 }); Assert.AreEqual("A", db.Table <Product>().FirstOrDefault().Name); db.ClearTable <Product>(); Assert.IsNull(db.Table <Product>().FirstOrDefault()); }
public void FirstTest() { var db = new OrmTestSession(); db.CreateTable <Product>(); db.Insert(new Product { Name = "A", Price = 20 }); Assert.AreEqual("A", db.Table <Product>().First().Name); db.ClearTable <Product>(); ExceptionAssert.Throws <InvalidOperationException>(() => db.Table <Product>().First()); }
public void FirstTest() { OrmTestSession db = CreateDb(); db.Insert(new Product { Name = "A", Price = 20 }); Assert.AreEqual("A", db.Table <Product>().First().Name); db.ClearTable <Product>(); try { db.Table <Product>().First(); Assert.Fail(); } catch (InvalidOperationException) { } }