Пример #1
0
        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 TestDateTimeMicroSeconds()
        {
            int           testId = -1;
            AggregateTest test   = new AggregateTest();

            switch (test.es.Connection.ProviderSignature.DataProviderName)
            {
            case "EntitySpaces.MSAccessProvider":
                Assert.Ignore("MS Access only resolves to MilliSeconds.");
                break;

            case "EntitySpaces.MySqlClientProvider":
                Assert.Ignore("Not supported.");
                break;

            case "EntitySpaces.SqlServerCeProvider":
            case "EntitySpaces.SqlServerCe4Provider":
            case "EntitySpaces.SqlClientProvider":
                Assert.Ignore("Requires SQL Server 2008 and datetime2 data type.");
                break;

            default:
                try
                {
                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        test.HireDate = Convert.ToDateTime("1902-01-01 01:01:01.000001");
                        test.Save();
                        testId = test.Id.Value;

                        test = new AggregateTest();
                        Assert.IsTrue(test.LoadByPrimaryKey(testId));
                        Assert.AreEqual(Convert.ToDateTime("1902-01-01 01:01:01.000001"), test.HireDate.Value, "MicroSeconds");
                    }
                }
                finally
                {
                    // Clean up
                    test = new AggregateTest();
                    if (test.LoadByPrimaryKey(testId))
                    {
                        test.MarkAsDeleted();
                        test.Save();
                    }
                }
                break;
            }
        }
Пример #3
0
        public void WhereLikeEscapedMultiWithSubOp()
        {
            int tempId = -1;
            AggregateTestCollection collection = new AggregateTestCollection();
            AggregateTest           aggTest    = new AggregateTest();

            switch (collection.es.Connection.ProviderSignature.DataProviderName)
            {
            case "EntitySpaces.MSAccessProvider":
                Assert.Ignore("Not supported.");
                break;

            default:
                try
                {
                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        aggTest.LastName = "a 10% name";
                        aggTest.Save();
                        tempId = aggTest.Id.Value;

                        collection.Query
                        .Select()
                        .Where
                        (
                            collection.Query.LastName.Trim().Like("%10!%%", '!'),
                            collection.Query.LastName.Like("%a%")
                        );
                        Assert.IsTrue(collection.Query.Load());
                        Assert.AreEqual(1, collection.Count);
                    }
                }
                finally
                {
                    // Clean up
                    aggTest = new AggregateTest();
                    if (aggTest.LoadByPrimaryKey(tempId))
                    {
                        aggTest.MarkAsDeleted();
                        aggTest.Save();
                    }
                }
                break;
            }
        }
Пример #4
0
        public void TestTransactions()
        {
            switch (aggTest.es.Connection.Name)
            {
            case "SQLStoredProcEnterprise":
            case "SQLDynamicEnterprise":
            case "ORACLEStoredProcEnterprise":
            case "ORACLEDynamicEnterprise":
            case "VistaDBDynamic":
                Assert.Ignore("Using esTransactionScope only");
                break;

            default:
                int tempId1 = 0;
                int tempId2 = 0;

                aggTest = new AggregateTest();
                AggregateTest aggTest2 = new AggregateTest();

                using (esTransactionScope scope = new esTransactionScope())
                {
                    aggTest.Save();
                    tempId1 = aggTest.Id.Value;
                    aggTest2.Save();
                    tempId2 = aggTest2.Id.Value;

                    scope.Complete();
                }

                aggTest = new AggregateTest();
                Assert.IsTrue(aggTest.LoadByPrimaryKey(tempId1));
                aggTest.MarkAsDeleted();
                aggTest.Save();

                aggTest = new AggregateTest();
                Assert.IsTrue(aggTest.LoadByPrimaryKey(tempId2));
                aggTest.MarkAsDeleted();
                aggTest.Save();

                break;
            }
        }
        public void TestDateTime()
        {
            int testId = -1;
            AggregateTestCollection aggTestColl = new AggregateTestCollection();
            AggregateTest           test        = new AggregateTest();

            try
            {
                using (EntitySpaces.Interfaces.esTransactionScope scope =
                           new EntitySpaces.Interfaces.esTransactionScope())
                {
                    aggTestColl.Query.Load();
                    aggTestColl.Filter = aggTestColl.AsQueryable().OrderBy(s => s.Id);
                    test = (AggregateTest)aggTestColl[0];
                    DateTime date = test.HireDate.Value;
                    Assert.AreEqual(Convert.ToDateTime("02/16/2000 05:59:31"), date);

                    test          = new AggregateTest();
                    test.HireDate = Convert.ToDateTime("12/31/9999");
                    test.Save();
                    testId = test.Id.Value;

                    test = new AggregateTest();
                    Assert.IsTrue(test.LoadByPrimaryKey(testId));
                    Assert.AreEqual(Convert.ToDateTime("12/31/9999"), test.HireDate.Value);
                    test.MarkAsDeleted();
                    test.Save();
                }
            }
            finally
            {
                // Clean up
                test = new AggregateTest();
                if (test.LoadByPrimaryKey(testId))
                {
                    test.MarkAsDeleted();
                    test.Save();
                }
            }
        }
Пример #6
0
        public void TestTransactionWithoutComplete()
        {
            switch (aggTest.es.Connection.Name)
            {
            case "SQLStoredProcEnterprise":
            case "SQLDynamicEnterprise":
            case "ORACLEStoredProcEnterprise":
            case "ORACLEDynamicEnterprise":
            case "VistaDBDynamic":
                Assert.Ignore("Using esTransactionScope only");
                break;

            default:
                int tempId = 0;
                try
                {
                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        aggTest.Save();
                        tempId = aggTest.Id.Value;
                    }
                    aggTest = new AggregateTest();
                    Assert.IsFalse(aggTest.LoadByPrimaryKey(tempId));
                }
                finally
                {
                    aggTest = new AggregateTest();
                    if (aggTest.LoadByPrimaryKey(tempId))
                    {
                        aggTest.MarkAsDeleted();
                        aggTest.Save();
                    }
                }
                break;
            }
        }