コード例 #1
0
        public void TestDeleteOnCollection()
        {
            aggTestColl = new AggregateTestCollection();

            AggregateTest aggTest = aggTestColl.AddNew();

            aggTest.FirstName = "Mike";

            aggTestColl.AcceptChanges();
            Assert.IsFalse(aggTestColl.IsDirty);

            // Let's mark it as deleted
            aggTest.MarkAsDeleted();
            Assert.IsTrue(aggTestColl.IsDirty);
        }
コード例 #2
0
        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;
            }
        }
コード例 #5
0
        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 TestDeleteOnEntity()
        {
            aggTest           = new AggregateTest();
            aggTest.FirstName = "Mike";
            aggTest.AcceptChanges();

            Assert.IsFalse(aggTest.es.IsAdded);
            Assert.IsFalse(aggTest.es.IsDeleted);
            Assert.IsFalse(aggTest.es.IsModified);
            Assert.IsFalse(aggTest.es.IsDirty);
            Assert.IsTrue(aggTest.es.ModifiedColumns.Count == 0);
            Assert.IsTrue(aggTest.es.RowState == esDataRowState.Unchanged);

            // Let's mark it as deleted
            aggTest.MarkAsDeleted();

            Assert.IsFalse(aggTest.es.IsAdded);
            Assert.IsTrue(aggTest.es.IsDeleted);
            Assert.IsFalse(aggTest.es.IsModified);
            Assert.IsTrue(aggTest.es.IsDirty);
            Assert.IsTrue(aggTest.es.ModifiedColumns.Count == 0);
            Assert.IsTrue(aggTest.es.RowState == esDataRowState.Deleted);
        }
コード例 #7
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;
            }
        }