public void TestDeleteCustomerWithDeleteCheckThatSucceeds() { this.TestInsertCustomerNoResult(); var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; var result = db.Customers.Delete(cust, d => d.City == "Seattle"); Assert.Equal(1, result); }
public void TestInsertCustomerNoResult() { var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; var result = db.Customers.Insert(cust); Assert.Equal(1, result); // returns 1 for success }
public void TestUpsertNewCustomerWithUpdateCheck() { var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Portland", // moved to Portland! Country = "USA" }; var result = db.Customers.InsertOrUpdate(cust, d => d.City == "Portland"); Assert.Equal(1, result); }
public void TestDeleteCustomerWithDeleteCheckThatDoesNotSucceed() { this.TestInsertCustomerNoResult(); var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; var result = db.Customers.Delete(cust, d => d.City == "Portland"); this.AssertValue(0, result); }
public void TestUpdateCustomerWithResult() { this.TestInsertCustomerNoResult(); // create customer "XX1" var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Portland", // moved to Portland! Country = "USA" }; var result = db.Customers.Update(cust, null, c => c.City); Assert.Equal("Portland", result); }
public void TestUpsertExistingCustomerWithResult() { this.TestInsertCustomerNoResult(); var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Portland", // moved to Portland! Country = "USA" }; var result = db.Customers.InsertOrUpdate(cust, null, d => d.City); Assert.Equal("Portland", result); }
public void TestUpsertNewCustomerNoResult() { var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", // moved to Portland! Country = "USA" }; var result = db.Customers.InsertOrUpdate(cust); this.AssertValue(1, result); }
public void TestSessionSubmitActionOnModify() { var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; this.db.Customers.Insert(cust); var ns = new NorthwindSession(this.GetProvider()); Assert.Equal(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); // fetch the previously inserted customer cust = ns.Customers.Single(c => c.CustomerID == "XX1"); Assert.Equal(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); cust.ContactName = "Contact Modified"; Assert.Equal(SubmitAction.Update, ns.Customers.GetSubmitAction(cust)); ns.SubmitChanges(); Assert.Equal(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); // prove actually modified by fetching through provider var cust2 = this.db.Customers.Single(c => c.CustomerID == "XX1"); Assert.Equal("Contact Modified", cust2.ContactName); // ready to be submitted again! cust.City = "SeattleX"; Assert.Equal(SubmitAction.Update, ns.Customers.GetSubmitAction(cust)); }
public void TestUpdateCustomerWithUpdateCheckThatDoesNotSucceed() { this.TestInsertCustomerNoResult(); // create customer "XX1" var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Portland", // moved to Portland! Country = "USA" }; var result = db.Customers.Update(cust, d => d.City == "Detroit"); this.AssertValue(0, result); // 0 for failure }
public void TestUpsertExistingCustomerWithUpdateCheck() { this.TestInsertCustomerNoResult(); var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Portland", // moved to Portland! Country = "USA" }; var result = db.Customers.InsertOrUpdate(cust, d => d.City == "Seattle"); this.AssertValue(1, result); }
public void TestUpdateCustomerNoResult() { this.TestInsertCustomerNoResult(); // create customer "XX1" var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Portland", // moved to Portland! Country = "USA" }; var result = db.Customers.Update(cust); this.AssertValue(1, result); }
public void TestSessionSubmitActionOnInsert() { NorthwindSession ns = new NorthwindSession(this.provider); var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; AssertValue(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); ns.Customers.InsertOnSubmit(cust); AssertValue(SubmitAction.Insert, ns.Customers.GetSubmitAction(cust)); ns.SubmitChanges(); AssertValue(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); cust.City = "SeattleX"; AssertValue(SubmitAction.Update, ns.Customers.GetSubmitAction(cust)); }
public void TestSessionSubmitActionOnDelete() { var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; this.db.Customers.Insert(cust); NorthwindSession ns = new NorthwindSession(this.provider); AssertValue(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); ns.Customers.DeleteOnSubmit(cust); AssertValue(SubmitAction.Delete, ns.Customers.GetSubmitAction(cust)); ns.SubmitChanges(); AssertValue(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); // modifications after delete don't trigger updates cust.City = "SeattleX"; AssertValue(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); }
public void TestInsertCustomerWithResult() { var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; var result = db.Customers.Insert(cust, c => c.City); Assert.Equal(result, "Seattle"); // should be value we asked for }
public void TestCompareEntityEqual() { Customer alfki = new Customer { CustomerID = "ALFKI" }; var list = db.Customers.Where(c => c == alfki).ToList(); AssertValue(1, list.Count); AssertValue("ALFKI", list[0].CustomerID); }
public void TestInsertThenDeleteSamePK() { var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; var cust2 = new Customer { CustomerID = "XX1", CompanyName = "Company2", ContactName = "Contact2", City = "Chicago", Country = "USA" }; this.db.Customers.Insert(cust); NorthwindSession ns = new NorthwindSession(this.GetProvider()); Assert.Equal(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); Assert.Equal(SubmitAction.None, ns.Customers.GetSubmitAction(cust2)); ns.Customers.InsertOnSubmit(cust2); Assert.Equal(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); Assert.Equal(SubmitAction.Insert, ns.Customers.GetSubmitAction(cust2)); ns.Customers.DeleteOnSubmit(cust); Assert.Equal(SubmitAction.Delete, ns.Customers.GetSubmitAction(cust)); Assert.Equal(SubmitAction.Insert, ns.Customers.GetSubmitAction(cust2)); ns.SubmitChanges(); Assert.Equal(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); Assert.Equal(SubmitAction.None, ns.Customers.GetSubmitAction(cust2)); // modifications after delete don't trigger updates cust.City = "SeattleX"; Assert.Equal(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); // modifications after insert do trigger updates cust2.City = "ChicagoX"; Assert.Equal(SubmitAction.Update, ns.Customers.GetSubmitAction(cust2)); }
public void TestCompareEntityEntityEqualRelationship() { Customer alfki = new Customer { CustomerID = "ALFKI" }; var testQuery = from o in db.Orders from c in db.Customers where o.Customer == c && c.CustomerID == alfki.CustomerID select o; var test = testQuery.ToList(); AssertValue(6, test.Count); AssertValue("ALFKI", test[0].CustomerID); }
public void TestSessionSubmitActionOnUpdate() { var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; this.db.Customers.Insert(cust); NorthwindSession ns = new NorthwindSession(this.GetProvider()); Assert.Equal(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); ns.Customers.UpdateOnSubmit(cust); Assert.Equal(SubmitAction.Update, ns.Customers.GetSubmitAction(cust)); ns.SubmitChanges(); Assert.Equal(SubmitAction.None, ns.Customers.GetSubmitAction(cust)); cust.City = "SeattleX"; Assert.Equal(SubmitAction.Update, ns.Customers.GetSubmitAction(cust)); }
public void TestCompareEntityConstantDirectEqualRelationship() { Customer alfki = new Customer { CustomerID = "ALFKI" }; var testQuery = from c in db.Customers where c == alfki select c; var test = testQuery.ToList(); AssertValue(1, test.Count); AssertValue("ALFKI", test[0].CustomerID); }
public void TestUpdateCustomerWithUpdateCheckThatSucceeds() { this.TestInsertCustomerNoResult(); // create customer "XX1" var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Portland", // moved to Portland! Country = "USA" }; var result = db.Customers.Update(cust, d => d.City == "Seattle"); Assert.Equal(1, result); }
public void TestCompareTwoConstantEntityNestedRelationshipNegation() { Order exclude = new Order() { OrderID = 10702 }; Customer alfki = new Customer() { CustomerID = "ALFKI" }; var testQuery = from o in db.Orders where o.Customer == alfki && o != exclude select o; var test = testQuery.ToList(); AssertValue(5, test.Count); AssertValue("ALFKI", test[0].CustomerID); }
public void TestUpsertNewCustomerWithResult() { var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", // moved to Portland! Country = "USA" }; var result = db.Customers.InsertOrUpdate(cust, null, d => d.City); Assert.Equal("Seattle", result); }
public void TestDeleteCustomerForNonExistingCustomer() { this.TestInsertCustomerNoResult(); var cust = new Customer { CustomerID = "XX2", CompanyName = "Company2", ContactName = "Contact2", City = "Seattle", Country = "USA" }; var result = db.Customers.Delete(cust); Assert.Equal(0, result); }
public void TestCompareEntityNotEqual() { Customer alfki = new Customer { CustomerID = "ALFKI" }; var list = db.Customers.Where(c => c != alfki).ToList(); this.AssertValue(90, list.Count); }
public void TestDeleteCustomer() { this.TestInsertCustomerNoResult(); var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; var result = db.Customers.Delete(cust); this.AssertValue(1, result); }