public void EntityTop() { aggTest.Query .Select() .Where ( aggTest.Query.FirstName.Equal("Sarah"), aggTest.Query.LastName.Equal("McDonald") ); aggTest.Query.es.Top = 1; Assert.IsTrue(aggTest.Query.Load()); Assert.AreEqual("McDonald", aggTest.str().LastName); Assert.AreEqual("Sarah", aggTest.str().FirstName); }
public void SerializeDeserializeFindEntityBinary() { int key = 0; aggTestColl.LoadAll(); foreach (AggregateTest test in aggTestColl) { if (test.LastName == "Doe") { key = test.Id.Value; break; } } aggTest = aggTestColl.FindByPrimaryKey(key); BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, aggTest); ms.Position = 0; aggClone = (AggregateTest)bf.Deserialize(ms); ms.Close(); Assert.AreEqual("Doe", aggClone.str().LastName); }
public void SerializeDeserializeLoadEntityBinary() { if (aggTest.es.Connection.Name == "SqlCe") { Assert.Ignore("Not tested for SqlCe."); } else { int key = 0; aggTest.Query.Where( aggTest.Query.LastName == "Douglas", aggTest.Query.FirstName == "Fred"); aggTest.Query.Load(); key = aggTest.Id.Value; aggTest = new AggregateTest(); aggTest.LoadByPrimaryKey(key); BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, aggTest); ms.Position = 0; aggClone = (AggregateTest)bf.Deserialize(ms); ms.Close(); Assert.AreEqual("Douglas", aggClone.str().LastName); } }
public void EntityLoadByPrimaryKey() { aggTest.Query .Select() .Where ( aggTest.Query.FirstName.Equal("Sarah"), aggTest.Query.LastName.Equal("Doe") ); Assert.IsTrue(aggTest.Query.Load()); int primaryKey = aggTest.Id.Value; Assert.IsTrue(aggClone.LoadByPrimaryKey(primaryKey)); Assert.AreEqual("Doe", aggClone.str().LastName); Assert.AreEqual("Sarah", aggClone.str().FirstName); }
public void CollectionFindByPrimaryKey() { AggregateTest aggTest = new AggregateTest(); aggTest.Query .Select() .Where ( aggTest.Query.FirstName.Equal("Sarah"), aggTest.Query.LastName.Equal("Doe") ); Assert.IsTrue(aggTest.Query.Load()); int primaryKey = aggTest.Id.Value; AggregateTestCollection aggCloneColl = new AggregateTestCollection(); aggCloneColl.LoadAll(); AggregateTest aggClone = aggCloneColl.FindByPrimaryKey(primaryKey); Assert.AreEqual("Doe", aggClone.str().LastName); Assert.AreEqual("Sarah", aggClone.str().FirstName); }
public void TestFailedTransaction() { switch (aggTest.es.Connection.Name) { case "SQLStoredProcEnterprise": case "SQLDynamicEnterprise": case "ORACLEStoredProcEnterprise": case "ORACLEDynamicEnterprise": case "VistaDBDynamic": Assert.Ignore("Using esTransactionScope only"); break; default: try { aggTest = new AggregateTest(); AggregateTest aggTest2 = new AggregateTest(); int tempId1 = -1; int tempId2 = -1; aggTest2.str().HireDate = "1/1/1"; using (esTransactionScope scope = new esTransactionScope()) { try { aggTest.Save(); tempId1 = aggTest.Id.Value; aggTest2.Save(); tempId2 = aggTest2.Id.Value; throw new Exception(); scope.Complete(); } catch { } } aggTest = new AggregateTest(); Assert.IsFalse(aggTest.LoadByPrimaryKey(tempId1)); aggTest = new AggregateTest(); Assert.IsFalse(aggTest.LoadByPrimaryKey(tempId2)); } catch (Exception ex) { Assert.Fail(ex.ToString()); } break; } }
public void EntityQueryReset() { aggTest.Query .Where ( aggTest.Query.FirstName.Equal("Sarah"), aggTest.Query.LastName.Equal("Doe") ); Assert.IsTrue(aggTest.Query.Load()); aggTest = new AggregateTest(); aggTest.Query .Where ( aggTest.Query.FirstName.Equal("Fred"), aggTest.Query.LastName.Equal("Costner") ); aggTest.Query.Load(); Assert.IsTrue(aggTest.Query.Load()); Assert.AreEqual("Costner", aggTest.str().LastName); Assert.AreEqual("Fred", aggTest.str().FirstName); }
public void SerializeDeserializeNewEntityBinary() { if (aggTest.es.Connection.Name == "SqlCe") { Assert.Ignore("Not tested for SqlCe."); } else { aggTest.LastName = "Griffinski"; BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, aggTest); ms.Position = 0; aggClone = (AggregateTest)bf.Deserialize(ms); ms.Close(); Assert.AreEqual("Griffinski", aggClone.str().LastName); } }
public static void RefreshDatabase(string connectionName) { AggregateTestCollection aggTestColl = new AggregateTestCollection(); if (connectionName.Length != 0) { aggTestColl.es.Connection.Name = connectionName; } aggTestColl.LoadAll(); aggTestColl.MarkAllAsDeleted(); aggTestColl.Save(); aggTestColl = new AggregateTestCollection(); AggregateTest aggTest = new AggregateTest(); if (connectionName.Length != 0) { aggTestColl.es.Connection.Name = connectionName; aggTest.es.Connection.Name = connectionName; } aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "3"; aggTest.str().FirstName = "David"; aggTest.str().LastName = "Doe"; aggTest.str().Age = "16"; aggTest.str().HireDate = "2000-02-16 05:59:31"; aggTest.str().Salary = "34.71"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "1"; aggTest.str().FirstName = "Sarah"; aggTest.str().LastName = "McDonald"; aggTest.str().Age = "28"; aggTest.str().HireDate = "1999-03-25 00:00:00"; aggTest.str().Salary = "11.06"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "3"; aggTest.str().FirstName = "David"; aggTest.str().LastName = "Vincent"; aggTest.str().Age = "43"; aggTest.str().HireDate = "2000-10-17 00:00:00"; aggTest.str().Salary = "10.27"; aggTest.str().IsActive = "false"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "2"; aggTest.str().FirstName = "Fred"; aggTest.str().LastName = "Smith"; aggTest.str().Age = "15"; aggTest.str().HireDate = "1999-03-15 00:00:00"; aggTest.str().Salary = "15.15"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "3"; aggTest.str().FirstName = "Sally"; aggTest.str().LastName = "Johnson"; aggTest.str().Age = "30"; aggTest.str().HireDate = "2000-10-07 00:00:00"; aggTest.str().Salary = "14.36"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "5"; aggTest.str().FirstName = "Jane"; aggTest.str().LastName = "Rapaport"; aggTest.str().Age = "44"; aggTest.str().HireDate = "2002-05-02 00:00:00"; aggTest.str().Salary = "13.56"; aggTest.str().IsActive = "false"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "4"; aggTest.str().FirstName = "Paul"; aggTest.str().LastName = "Gellar"; aggTest.str().Age = "16"; aggTest.str().HireDate = "2000-09-27 00:00:00"; aggTest.str().Salary = "18.44"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "2"; aggTest.str().FirstName = "John"; aggTest.str().LastName = "Jones"; aggTest.str().Age = "31"; aggTest.str().HireDate = "2002-04-22 00:00:00"; aggTest.str().Salary = "17.65"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "3"; aggTest.str().FirstName = "Michelle"; aggTest.str().LastName = "Johnson"; aggTest.str().Age = "45"; aggTest.str().HireDate = "2003-11-14 00:00:00"; aggTest.str().Salary = "16.86"; aggTest.str().IsActive = "false"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "2"; aggTest.str().FirstName = "David"; aggTest.str().LastName = "Costner"; aggTest.str().Age = "17"; aggTest.str().HireDate = "2002-04-11 00:00:00"; aggTest.str().Salary = "21.74"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "4"; aggTest.str().FirstName = "William"; aggTest.str().LastName = "Gellar"; aggTest.str().Age = "32"; aggTest.str().HireDate = "2003-11-04 00:00:00"; aggTest.str().Salary = "20.94"; aggTest.str().IsActive = "false"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "3"; aggTest.str().FirstName = "Sally"; aggTest.str().LastName = "Rapaport"; aggTest.str().Age = "39"; aggTest.str().HireDate = "2002-04-01 00:00:00"; aggTest.str().Salary = "25.82"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "5"; aggTest.str().FirstName = "Jane"; aggTest.str().LastName = "Vincent"; aggTest.str().Age = "18"; aggTest.str().HireDate = "2003-10-25 00:00:00"; aggTest.str().Salary = "25.03"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "2"; aggTest.str().FirstName = "Fred"; aggTest.str().LastName = "Costner"; aggTest.str().Age = "33"; aggTest.str().HireDate = "1998-05-20 00:00:00"; aggTest.str().Salary = "24.24"; aggTest.str().IsActive = "false"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "1"; aggTest.str().FirstName = "John"; aggTest.str().LastName = "Johnson"; aggTest.str().Age = "40"; aggTest.str().HireDate = "2003-10-15 00:00:00"; aggTest.str().Salary = "29.12"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "3"; aggTest.str().FirstName = "Michelle"; aggTest.str().LastName = "Rapaport"; aggTest.str().Age = "19"; aggTest.str().HireDate = "1998-05-10 00:00:00"; aggTest.str().Salary = "28.32"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "4"; aggTest.str().FirstName = "Sarah"; aggTest.str().LastName = "Doe"; aggTest.str().Age = "34"; aggTest.str().HireDate = "1999-12-03 00:00:00"; aggTest.str().Salary = "27.53"; aggTest.str().IsActive = "false"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "4"; aggTest.str().FirstName = "William"; aggTest.str().LastName = "Jones"; aggTest.str().Age = "41"; aggTest.str().HireDate = "1998-04-30 00:00:00"; aggTest.str().Salary = "32.41"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "1"; aggTest.str().FirstName = "Sarah"; aggTest.str().LastName = "McDonald"; aggTest.str().Age = "21"; aggTest.str().HireDate = "1999-11-23 00:00:00"; aggTest.str().Salary = "31.62"; aggTest.str().IsActive = "false"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "4"; aggTest.str().FirstName = "Jane"; aggTest.str().LastName = "Costner"; aggTest.str().Age = "28"; aggTest.str().HireDate = "1998-04-20 00:00:00"; aggTest.str().Salary = "36.50"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "2"; aggTest.str().FirstName = "Fred"; aggTest.str().LastName = "Douglas"; aggTest.str().Age = "42"; aggTest.str().HireDate = "1999-11-13 00:00:00"; aggTest.str().Salary = "35.71"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "3"; aggTest.str().FirstName = "Sarah"; aggTest.str().LastName = "Jones"; aggTest.str().Age = "22"; aggTest.str().HireDate = "2001-06-07 00:00:00"; aggTest.str().Salary = "34.91"; aggTest.str().IsActive = "false"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "3"; aggTest.str().FirstName = "Michelle"; aggTest.str().LastName = "Doe"; aggTest.str().Age = "29"; aggTest.str().HireDate = "1999-11-03 00:00:00"; aggTest.str().Salary = "39.79"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "4"; aggTest.str().FirstName = "Paul"; aggTest.str().LastName = "Costner"; aggTest.str().Age = "43"; aggTest.str().HireDate = "2001-05-28 00:00:00"; aggTest.str().Salary = "39.00"; aggTest.str().IsActive = "true"; aggTest = aggTestColl.AddNew(); aggTest.str().DepartmentID = "0"; aggTest.str().FirstName = ""; aggTest.str().LastName = ""; aggTest.str().Age = "0"; aggTest.str().Salary = "0"; aggTest = aggTestColl.AddNew(); aggTest = aggTestColl.AddNew(); aggTest = aggTestColl.AddNew(); aggTest = aggTestColl.AddNew(); aggTest = aggTestColl.AddNew(); aggTestColl.Save(); }