コード例 #1
0
 public void TestDelimitedTableNameWithSpaces()
 {
     ClassDef.ClassDefs.Clear();
     TestAutoInc.LoadClassDefWithAutoIncrementingID();
     TestAutoInc bo = new TestAutoInc();
     bo.Save();
     ClassDef.ClassDefs[typeof(TestAutoInc)].TableName = "test autoinc";
     bo.TestField = TestUtil.GetRandomString();
     UpdateStatementGenerator gen = new UpdateStatementGenerator(bo, DatabaseConnection.CurrentConnection);
     var statementCol = gen.Generate();
     ISqlStatement statement = statementCol.First();
     StringAssert.Contains("`test autoinc`", statement.Statement.ToString());
 }
コード例 #2
0
        public void TestDelimitedTableNameWithSpaces_SqlServer()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();
            TestAutoInc bo = new TestAutoInc();
            bo.Save();
            ClassDef.ClassDefs[typeof(TestAutoInc)].TableName = "test autoinc";
            bo.TestField = TestUtil.GetRandomString();
            var gen = CreateUpdateStatementGenerator(bo, DatabaseConfig.SqlServer);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var statementCol = gen.Generate();
            //---------------Test Result -----------------------
            ISqlStatement statement = statementCol.First();
            StringAssert.Contains("[test autoinc]", statement.Statement.ToString());
        }
コード例 #3
0
        public void TestGetBusinessObjectByIDIntSavenewAutoIncNumber()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();
            TestAutoInc autoInc = new TestAutoInc();

            autoInc.Save();

            //---------------Execute Test ----------------------
            Criteria    criteria = new Criteria("testautoincid", Criteria.ComparisonOp.Equals, autoInc.TestAutoIncID);
            TestAutoInc tai1     = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <TestAutoInc>(criteria);
            TestAutoInc tai2     = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <TestAutoInc>(tai1.ID);

            ////---------------Test Result -----------------------
            Assert.AreSame(tai1, tai2);
            Assert.AreEqual("testing", tai2.TestField);
        }
コード例 #4
0
        public void TestDelimitedTableNameWithSpaces_SqlServer()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();
            TestAutoInc bo = new TestAutoInc();

            bo.Save();
            ClassDef.ClassDefs[typeof(TestAutoInc)].TableName = "test autoinc";
            bo.TestField = TestUtil.GetRandomString();
            var gen = CreateUpdateStatementGenerator(bo, DatabaseConfig.SqlServer);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var statementCol = gen.Generate();
            //---------------Test Result -----------------------
            ISqlStatement statement = statementCol.First();

            StringAssert.Contains("[test autoinc]", statement.Statement.ToString());
        }
コード例 #5
0
 public void TestSaveUpdatesAutoIncrementingField()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     TestAutoInc.LoadClassDefWithAutoIncrementingID();
     var newIds = new ConcurrentBag<int?>();
     //---------------Execute Test ----------------------
     Parallel.For(0, 1000, i => {
                                    //---------------Set up test pack-------------------
                                    var bo = new TestAutoInc();
                                    bo.SetPropertyValue("testfield", "testing 123");
                                    //---------------Assert Precondition----------------
                                    Assert.IsFalse(bo.TestAutoIncID.HasValue);
                                    //---------------Execute Test ----------------------
                                    bo.Save();
                                    //---------------Test Result -----------------------
                                    newIds.Add(bo.TestAutoIncID);
     });
     //---------------Test Result -----------------------
     Assert.IsTrue(newIds.All(i => i.HasValue));
     Assert.IsTrue(newIds.All(i => i > 0));
     Assert.That(newIds.Distinct().Count(), Is.EqualTo(1000), "Every generated ID must be unique");
 }
コード例 #6
0
        public void TestSaveUpdatesAutoIncrementingField()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();
            var newIds = new ConcurrentBag <int?>();

            //---------------Execute Test ----------------------
            Parallel.For(0, 1000, i => {
                //---------------Set up test pack-------------------
                var bo = new TestAutoInc();
                bo.SetPropertyValue("testfield", "testing 123");
                //---------------Assert Precondition----------------
                Assert.IsFalse(bo.TestAutoIncID.HasValue);
                //---------------Execute Test ----------------------
                bo.Save();
                //---------------Test Result -----------------------
                newIds.Add(bo.TestAutoIncID);
            });
            //---------------Test Result -----------------------
            Assert.IsTrue(newIds.All(i => i.HasValue));
            Assert.IsTrue(newIds.All(i => i > 0));
            Assert.That(newIds.Distinct().Count(), Is.EqualTo(1000), "Every generated ID must be unique");
        }
コード例 #7
0
 public void TestSaveUpdatesAutoIncrementingField()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     TestAutoInc.LoadClassDefWithAutoIncrementingID();
     TestAutoInc bo = new TestAutoInc();
     bo.SetPropertyValue("testfield", "testing 123");
     //---------------Assert Precondition----------------
     Assert.IsFalse(bo.TestAutoIncID.HasValue);
     //---------------Execute Test ----------------------
     bo.Save();
     //---------------Test Result -----------------------
     Assert.IsNotNull(bo.TestAutoIncID);
     Assert.AreNotEqual(0, bo.TestAutoIncID);
     Assert.IsFalse(bo.Status.IsDirty);
 }
コード例 #8
0
        public void TestGetBusinessObjectByIDIntSavenewAutoIncNumber()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();
            TestAutoInc autoInc = new TestAutoInc();
            autoInc.Save();

            //---------------Execute Test ----------------------
            Criteria criteria = new Criteria("testautoincid", Criteria.ComparisonOp.Equals, autoInc.TestAutoIncID);
            TestAutoInc tai1 = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject<TestAutoInc>(criteria);
            TestAutoInc tai2 = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject<TestAutoInc>(tai1.ID);

            ////---------------Test Result -----------------------
            Assert.AreSame(tai1, tai2);
            Assert.AreEqual("testing", tai2.TestField);
        }
コード例 #9
0
        public void TestSaveUpdatesAutoIncrementingField()
        {
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();

            TestAutoInc bo = new TestAutoInc();
            bo.SetPropertyValue("testfield", "testing 123");
            Assert.IsFalse(bo.TestAutoIncID.HasValue);
            bo.Save();
            Assert.IsNotNull(bo.TestAutoIncID);
            Assert.AreNotEqual(0, bo.TestAutoIncID);
            Assert.IsFalse(bo.Status.IsDirty);
        }