public void CollectionLoadAllFalse()
		{
			AggregateTestCollection testColl = new AggregateTestCollection();

            try
            {
                testColl.LoadAll();
                testColl.MarkAllAsDeleted();
                testColl.Save();

                testColl = new AggregateTestCollection();
                Assert.IsFalse(testColl.LoadAll());
            }
            finally
            {
                UnitTestBase.RefreshDatabase();
            }
		}
		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();

        }
        public void FilteredDeleteAll()
        {
            using (esTransactionScope scope = new esTransactionScope())
            {
                AggregateTestCollection aggTestColl = new AggregateTestCollection();
                aggTestColl.LoadAll();
                Assert.AreEqual(30, aggTestColl.Count);
                aggTestColl.Filter = aggTestColl.AsQueryable().Where(f => f.LastName == "Doe");
                Assert.AreEqual(3, aggTestColl.Count);

                aggTestColl.MarkAllAsDeleted();

                aggTestColl.Filter = null;
                Assert.AreEqual(27, aggTestColl.Count);

                aggTestColl.Save();

                aggTestColl = new AggregateTestCollection();
                aggTestColl.LoadAll();
                Assert.AreEqual(27, aggTestColl.Count);
            }
        }