public void ErrorsWithContinueTrueInsUpd() { using (esTransactionScope scope = new esTransactionScope()) { EmployeeCollection coll = new EmployeeCollection(); coll.es.Connection.Name = "ForeignKeyTest"; // This employee should save fine Employee e = coll.AddNew(); e.FirstName = "Test1"; e.LastName = "K98700"; // Should fail, missing LastName e = coll.AddNew(); e.FirstName = "Joe"; // Should fail, missing FirstName e = coll.AddNew(); e.LastName = "Kokomo"; // This employee should save fine e = coll.AddNew(); e.FirstName = "Test4"; e.LastName = "K98700"; try { coll.Save(true); // ContinueUpdateOnError } catch { Assert.Fail("1. We shouldn't get here"); } Assert.IsTrue(coll.Errors.Count() == 2, "Count"); Assert.IsTrue(coll[0].es.RowState == esDataRowState.Unchanged, "Unchanged0"); Assert.IsTrue(coll[1].es.RowState == esDataRowState.Added, "Added1"); Assert.IsTrue(coll[2].es.RowState == esDataRowState.Added, "Added2"); Assert.IsTrue(coll[3].es.RowState == esDataRowState.Unchanged, "Unchanged3"); Assert.IsTrue(coll[0].EmployeeID != null, "Id0"); Assert.IsTrue(coll[1].EmployeeID == null, "Id1"); Assert.IsTrue(coll[2].EmployeeID == null, "Id2"); Assert.IsTrue(coll[3].EmployeeID != null, "Id3"); foreach (Employee emp in coll.Errors) { Assert.IsTrue(emp.es.RowState == esDataRowState.Added, "ForeachRowSate"); Assert.IsTrue(emp.es.RowError != null, "ForeachRowError"); Assert.IsTrue(emp.es.RowError.Length > 0, "ForeachLength"); } // Call Save again with the 2 bad records just for kicks try { coll.Save(true); // ContinueUpdateOnError } catch { Assert.Fail("2. We shouldn't get here, either"); } Assert.IsTrue(coll.Errors.Count() == 2); // Fix our two bad records and call Save again coll[1].LastName = "LastName"; coll[2].FirstName = "FirstName"; try { coll.Save(true); // ContinueUpdateOnError } catch { Assert.Fail("3. We shouldn't get here, either"); } Assert.IsTrue(coll.Errors.Count() == 0); // Load the two original records and see if they were saved even though during the // save there were two bad records coll = new EmployeeCollection(); coll.es.Connection.Name = "ForeignKeyTest"; coll.Query.Where(coll.Query.LastName == "K98700"); coll.Query.Load(); Assert.IsTrue(coll.Count() == 2, "FinalCount"); } }