public void TestSessionSubmitActionOnModify() { var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; this.Northwind.Customers.Insert(cust); NorthwindSession ns = new NorthwindSession(this.Northwind.Provider); Assert.AreEqual(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); // fetch the previously inserted customer cust = ns.Customers.Single(c => c.CustomerID == "XX1"); Assert.AreEqual(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); cust.ContactName = "Contact Modified"; Assert.AreEqual(SubmitAction.Update, ns.Customers.GetSubmitAction(cust)); ns.SubmitChanges(); Assert.AreEqual(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); // prove actually modified by fetching through provider var cust2 = this.Northwind.Customers.Single(c => c.CustomerID == "XX1"); Assert.AreEqual("Contact Modified", cust2.ContactName); // ready to be submitted again! cust.City = "SeattleX"; Assert.AreEqual(SubmitAction.Update, ns.Customers.GetSubmitAction(cust)); }
public void DbEntitySessionBaseTests_SessionSelectWithStringAsResultTest() { var context = new NorthwindContext(@"Northwind.dbc"); var session = new NorthwindSession(context); var list = session.Categories.Select(x => x.CategoryName).ToList(); Assert.AreEqual(8, list.Count); }
public void TestSessionIdentityCache() { NorthwindSession ns = new NorthwindSession(this.Northwind.Provider); // both objects should the same instance var cust = ns.Customers.Single(c => c.CustomerID == "ALFKI"); var cust2 = ns.Customers.Single(c => c.CustomerID == "ALFKI"); Assert.AreNotEqual(null, cust); Assert.AreNotEqual(null, cust2); Assert.AreEqual(cust, cust2); }
public void TestSessionProviderNotIdentityCached() { NorthwindSession ns = new NorthwindSession(this.Northwind.Provider); NorthwindDataContext db2 = new NorthwindDataContext(this.Northwind.Provider); var cust = ns.Customers.Single(c => c.CustomerID == "ALFKI"); var cust2 = ns.Customers.ProviderTable.Single(c => c.CustomerID == "ALFKI"); Assert.AreNotEqual(null, cust); Assert.AreNotEqual(null, cust2); Assert.AreEqual(cust.CustomerID, cust2.CustomerID); Assert.AreNotEqual(cust, cust2); }
public void DbEntitySessionBaseTests_InsertWithoutReturningTheAutoGeneratedPrimaryKeyValue_Test() { var context = new NorthwindContext(@"Northwind.dbc"); var session = new NorthwindSession(context); var category = new Category { CategoryName = "SessionCat" }; session.Categories.SetSubmitAction(category, SubmitAction.Insert); session.SubmitChanges(); Assert.AreEqual(0, category.CategoryId); Assert.IsNotNull(context.Categories.Where(x => x.CategoryName == category.CategoryName).SingleOrDefault()); }
public void TestSessionInsertCustomer() { NorthwindSession ns = new NorthwindSession(this.Northwind.Provider); var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; ns.Customers.InsertOnSubmit(cust); ns.SubmitChanges(); }
public void TestSessionSubmitActionOnInsertOrUpdate() { NorthwindSession ns = new NorthwindSession(this.Northwind.Provider); var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; Assert.AreEqual(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); ns.Customers.InsertOrUpdateOnSubmit(cust); Assert.AreEqual(SubmitAction.InsertOrUpdate, ns.Customers.GetSubmitAction(cust)); ns.SubmitChanges(); Assert.AreEqual(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); cust.City = "SeattleX"; Assert.AreEqual(SubmitAction.Update, ns.Customers.GetSubmitAction(cust)); }
public void TestSessionUpdateCustomer() { this.Northwind.Customers.Insert( new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }); var ns = new NorthwindSession(this.Northwind.Provider); // fetch the previously inserted customer var cust = ns.Customers.Single(c => c.CustomerID == "XX1"); cust.ContactName = "Contact Modified"; ns.SubmitChanges(); var cust2 = this.Northwind.Customers.Single(c => c.CustomerID == "XX1"); Assert.AreEqual("Contact Modified", cust2.ContactName); }
protected void Applicaton_EndRequest() { NorthwindSession.Dispose(); }
public void TestSessionCountPredicate() { var nw = new NorthwindSession(_provider); var count = nw.Customers.Count(c => c.City == "London"); AssertValue(6, count); }
public void TestSessionCount() { var nw = new NorthwindSession(_provider); var count = nw.Customers.Count(); AssertValue(91, count); }