public void Test_CommitTransaction_WithAutoIncrementBo_ShouldUseNumberGeneratorsInDatastore()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            IClassDef classDef = TestAutoInc.LoadClassDefWithAutoIncrementingID();

            DataStoreInMemory dataStore = MockRepository.GeneratePartialMock <DataStoreInMemory>();

            dataStore.Replay();

            int nextAutoIncNumber = TestUtil.GetRandomInt();

            dataStore.Stub(t => t.GetNextAutoIncrementingNumber(classDef)).Return(nextAutoIncNumber);

            ITransactionCommitter transactionCommitter = new TransactionCommitterInMemory(dataStore);

            TestAutoInc bo = new TestAutoInc();

            bo.SetPropertyValue("testfield", "testing 123");
            transactionCommitter.AddBusinessObject(bo);
            //---------------Assert Precondition----------------
            Assert.IsFalse(bo.TestAutoIncID.HasValue);
            Assert.AreSame(classDef, bo.ClassDef);
            Assert.IsTrue(bo.Props.HasAutoIncrementingField);
            //---------------Execute Test ----------------------
            transactionCommitter.CommitTransaction();
            //---------------Test Result -----------------------
            dataStore.AssertWasCalled(memory => memory.GetNextAutoIncrementingNumber(classDef));
            Assert.IsNotNull(bo.TestAutoIncID);
            Assert.AreEqual(nextAutoIncNumber, bo.TestAutoIncID);
            Assert.IsFalse(bo.Status.IsDirty);
        }
示例#2
0
        public void Test_InitialiseProp_InvalidBusinessObject_IDNotGuid()
        {
            //---------------Set up test pack-------------------
            TestAutoInc.LoadClassDefWithAutoIncrementingID();
            BOProp boProp = new BOProp(_propDef);
            //Use auto incrementing because it is the only bo prop that has
            TestAutoInc bo = new TestAutoInc();

            bo.SetPropertyValue("testautoincid", 1);
            //---------------Assert Precondition----------------
            Assert.IsNull(boProp.Value);
            //---------------Execute Test ----------------------
            try
            {
                boProp.InitialiseProp(bo);
                Assert.Fail("expected Err");
            }
            //---------------Test Result -----------------------
            catch (HabaneroDeveloperException ex)
            {
                StringAssert.Contains(boProp.PropertyName + " cannot be set to " + bo.ToString(), ex.Message);
                StringAssert.Contains("It is not a type of ", ex.Message);
                StringAssert.Contains("Guid", ex.Message);
                Assert.AreEqual(null, boProp.Value);
                Assert.IsTrue(boProp.IsValid);
            }
        }
示例#3
0
        public void TestAutoIncrementObj()
        {
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();
            TestAutoInc bo = new TestAutoInc();
            InsertStatementGenerator gen = new InsertStatementGenerator(bo, DatabaseConnection.CurrentConnection);
            var statementCol             = gen.Generate();
            InsertSqlStatement statement = (InsertSqlStatement)statementCol.First();

            Assert.AreSame(typeof(SupportsAutoIncrementingFieldBO), statement.SupportsAutoIncrementingField.GetType());
        }
        public void TestDelimitedTableNameWithSpaces()
        {
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();
            TestAutoInc bo = new TestAutoInc();
            ClassDef.ClassDefs[typeof (TestAutoInc)].TableName = "test autoinc";

            DeleteStatementGenerator gen = new DeleteStatementGenerator(bo, DatabaseConnection.CurrentConnection);
            var statementCol = gen.Generate();
            ISqlStatement statement = statementCol.First();
            StringAssert.Contains("`test autoinc`", statement.Statement.ToString());
        }
        public void TestDelimitedTableNameWithSpaces()
        {
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();
            TestAutoInc bo = new TestAutoInc();

            ClassDef.ClassDefs[typeof(TestAutoInc)].TableName = "test autoinc";

            DeleteStatementGenerator gen = new DeleteStatementGenerator(bo, DatabaseConnection.CurrentConnection);
            var           statementCol   = gen.Generate();
            ISqlStatement statement      = statementCol.First();
            var           tableName      = DatabaseConnection.CurrentConnection.SqlFormatter.DelimitTable("test autoinc");

            StringAssert.Contains(tableName, statement.Statement.ToString());
        }
示例#6
0
        public void Test_GetAsValue_Int()
        {
            //---------------Set up test pack-------------------
            TestAutoInc.LoadClassDefWithIntID();
            const int   expecteID = 4;
            TestAutoInc testBO    = new TestAutoInc {
                TestAutoIncID = expecteID
            };
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            object value = testBO.ID.GetAsValue();

            //---------------Test Result -----------------------
            Assert.AreEqual(expecteID, value);
        }
示例#7
0
        public void TestInsertStatementExcludesAutoField_MySql()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();
            TestAutoInc bo = new TestAutoInc();
            InsertStatementGenerator gen = CreateInsertStatementGenerator(bo, DatabaseConfig.MySql);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var statementCol = gen.Generate();
            //---------------Test Result -----------------------
            var statement = statementCol.First();

            Assert.AreEqual("INSERT INTO `testautoinc` (`testfield`) VALUES (?Param0)", statement.Statement.ToString());
        }
示例#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);
        }
        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());
        }
示例#10
0
        public void Test_DataMapper_ConvertValueToString_ValidBusinessObject()
        {
            //---------------Set up test pack-------------------
            TestAutoInc.LoadClassDefWithIntID();
            const int    validIntID          = 3;
            const string validvalue          = "ValidValue";
            TestAutoInc  validBusinessObject = new TestAutoInc {
                TestField = validvalue, TestAutoIncID = validIntID
            };

            //---------------Assert Precondition----------------
            Assert.AreEqual(validvalue, validBusinessObject.ToString());
            //---------------Execute Test ----------------------
            string parsedValue = _dataMapper.ConvertValueToString(validBusinessObject);

            //---------------Test Result -----------------------
            Assert.AreEqual(validIntID.ToString(), parsedValue);
        }
        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());
        }
示例#12
0
        public void Test_DataMapper_ParsePropValue_ValidBusinessObject()
        {
            //---------------Set up test pack-------------------
            TestAutoInc.LoadClassDefWithIntID();
            const int    validIntID          = 3;
            const string validvalue          = "ValidValue";
            TestAutoInc  validBusinessObject = new TestAutoInc {
                TestField = validvalue, TestAutoIncID = validIntID
            };

            //---------------Assert Precondition----------------
            Assert.AreEqual(validvalue, validBusinessObject.ToString());
            //---------------Execute Test ----------------------
            object parsedValue;
            bool   parsedSucceed = _dataMapper.TryParsePropValue(validBusinessObject, out parsedValue);

            //---------------Test Result -----------------------
            Assert.IsNotNull(parsedValue);
            Assert.IsTrue(parsedSucceed);
            Assert.AreEqual(validIntID, parsedValue);
        }
        public void Test_CommitTransaction_WithAutoIncrementBo_ShouldAutoIncrementAfterInsert()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();

            DataStoreInMemory     dataStore            = new DataStoreInMemory();
            ITransactionCommitter transactionCommitter = new TransactionCommitterInMemory(dataStore);

            TestAutoInc bo = new TestAutoInc();

            bo.SetPropertyValue("testfield", "testing 123");
            transactionCommitter.AddBusinessObject(bo);
            //---------------Assert Precondition----------------
            Assert.IsFalse(bo.TestAutoIncID.HasValue);
            //---------------Execute Test ----------------------
            transactionCommitter.CommitTransaction();
            //---------------Test Result -----------------------
            Assert.IsNotNull(bo.TestAutoIncID);
            Assert.AreNotEqual(0, bo.TestAutoIncID);
            Assert.IsFalse(bo.Status.IsDirty);
        }
 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");
 }
示例#15
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");
        }
        public void Test_CommitTransaction_WithAutoIncrementBo_ShouldAutoIncrementAfterInsert()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID(); 
            
            DataStoreInMemory dataStore = new DataStoreInMemory();
            ITransactionCommitter transactionCommitter = new TransactionCommitterInMemory(dataStore);

            TestAutoInc bo = new TestAutoInc();
            bo.SetPropertyValue("testfield", "testing 123");
            transactionCommitter.AddBusinessObject(bo);
            //---------------Assert Precondition----------------
            Assert.IsFalse(bo.TestAutoIncID.HasValue);
            //---------------Execute Test ----------------------
            transactionCommitter.CommitTransaction();
            //---------------Test Result -----------------------
            Assert.IsNotNull(bo.TestAutoIncID);
            Assert.AreNotEqual(0, bo.TestAutoIncID);
            Assert.IsFalse(bo.Status.IsDirty);
        }
示例#17
0
 public void Test_InitialiseProp_InvalidBusinessObject_IDNotGuid()
 {
     //---------------Set up test pack-------------------
     TestAutoInc.LoadClassDefWithAutoIncrementingID();
     BOProp boProp = new BOProp(_propDef);
     //Use auto incrementing because it is the only bo prop that has 
     TestAutoInc bo = new TestAutoInc();
     bo.SetPropertyValue("testautoincid", 1);
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     try
     {
         boProp.InitialiseProp(bo);
         Assert.Fail("expected Err");
     }
         //---------------Test Result -----------------------
     catch (HabaneroDeveloperException ex)
     {
         StringAssert.Contains(boProp.PropertyName + " cannot be set to " + bo.ToString(), ex.Message);
         StringAssert.Contains("It is not a type of ", ex.Message);
         StringAssert.Contains("Guid", ex.Message);
         Assert.AreEqual(null, boProp.Value);
         Assert.IsTrue(boProp.IsValid);
     }
 }
示例#18
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);
        }
        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);
        }
示例#20
0
        public void Test_GetProperty_FieldDoesNotExist()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();

            TestAutoInc bo = new TestAutoInc();
            //---------------Execute Test ----------------------

            const string nonexistentPropName = "nonExistent";
            try
            {
                bo.GetProperty(nonexistentPropName);
                Assert.Fail("expected Err");
            }
                //---------------Test Result -----------------------
            catch (InvalidPropertyNameException ex)
            {
                string errMessage = String.Format
                    ("The given property name '{0}' does not exist in the "
                     + "collection of properties for the class '{1}'.", nonexistentPropName, "TestAutoInc");
                StringAssert.Contains(errMessage, ex.Message);
            }
        }
示例#21
0
        public void Test_AddNullBOProp()
        {
            //---------------Set up test pack-------------------
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();

            TestAutoInc bo = new TestAutoInc();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------

            try
            {
                bo.Props.Add((IBOProp) null);
                Assert.Fail("expected ArgumentNullException");
            }
                //---------------Test Result -----------------------
            catch (ArgumentNullException ex)
            {
                StringAssert.Contains("Value cannot be null", ex.Message);
                StringAssert.Contains("boProp", ex.ParamName);
            }
        }
        public void TestInsertStatementExcludesAutoField()
        {
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();
            TestAutoInc bo = new TestAutoInc();
            InsertStatementGenerator gen = new InsertStatementGenerator(bo, DatabaseConnection.CurrentConnection);
            var statementCol = gen.Generate();
            InsertSqlStatement statement = (InsertSqlStatement)statementCol.First();

            Assert.AreEqual("INSERT INTO `testautoinc` (`testfield`) VALUES (?Param0)", statement.Statement.ToString());
        }
示例#23
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);
 }
示例#24
0
 public void Test_PropDef_ParsePropValue_ValidBusinessObject()
 {
     //---------------Set up test pack-------------------
     TestAutoInc.LoadClassDefWithIntID();
     const int validIntID = 3;
     const string validvalue = "ValidValue";
     TestAutoInc validBusinessObject = new TestAutoInc { TestField = validvalue, TestAutoIncID = validIntID };
     //---------------Assert Precondition----------------
     Assert.AreEqual(validvalue, validBusinessObject.ToString());
     //---------------Execute Test ----------------------
     object parsedValue;
     bool parsedSucceed = _propDef.TryParsePropValue(validBusinessObject, out parsedValue);
     //---------------Test Result -----------------------
     Assert.IsNotNull(parsedValue);
     Assert.IsTrue(parsedSucceed);
     Assert.AreEqual(validIntID, parsedValue);
 }
示例#25
0
 public void Test_DataMapper_ParsePropValue_ValidBusinessObject_ToStringZeroLength()
 {
     //---------------Set up test pack-------------------
     TestAutoInc.LoadClassDefWithIntID();
     const int validIntID = 3;
     const string zeroLengthString = "";
     TestAutoInc validBusinessObject = new TestAutoInc { TestField = zeroLengthString, TestAutoIncID = validIntID };
     //---------------Assert Precondition----------------
     Assert.AreEqual(zeroLengthString, validBusinessObject.ToString());
     Assert.AreEqual("", zeroLengthString);
     //---------------Execute Test ----------------------
     object parsedValue;
     bool parsedSucceed = _dataMapper.TryParsePropValue(validBusinessObject, out parsedValue);
     //---------------Test Result -----------------------
     Assert.IsNotNull(parsedValue);
     Assert.IsTrue(parsedSucceed);
     Assert.AreEqual(validIntID, parsedValue);
 }
示例#26
0
 public void Test_DataMapper_ConvertValueToString_ValidBusinessObject()
 {
     //---------------Set up test pack-------------------
     TestAutoInc.LoadClassDefWithIntID();
     const int validIntID = 3;
     const string validvalue = "ValidValue";
     TestAutoInc validBusinessObject = new TestAutoInc {TestField = validvalue, TestAutoIncID = validIntID};
     //---------------Assert Precondition----------------
     Assert.AreEqual(validvalue, validBusinessObject.ToString());
     //---------------Execute Test ----------------------
     string parsedValue = _dataMapper.ConvertValueToString(validBusinessObject);
     //---------------Test Result -----------------------
     Assert.AreEqual(validIntID.ToString(), parsedValue);
 }
        public void TestAutoIncrementingFieldInNewPrimaryKeyDoesntCheckDuplicates()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            TestAutoInc.LoadClassDefWithAutoIncrementingID();

            TestAutoInc bo = new TestAutoInc();
            bo.SetPropertyValue("testfield", "testing 123");

            MockRepository mockRepos = new MockRepository();
            IBusinessObjectLoader mockBusinessObjectLoader = mockRepos.DynamicMock<IBusinessObjectLoader>();

            Expect.Call(
                mockBusinessObjectLoader.GetBusinessObjectCollection(null, new Criteria("", Criteria.ComparisonOp.Equals, "")))
                .IgnoreArguments()
                .Repeat.Never();

            DataAccessorStub dataAccessor = new DataAccessorStub();
            dataAccessor.BusinessObjectLoader = mockBusinessObjectLoader;

            BORegistry.DataAccessor = dataAccessor;
            mockRepos.ReplayAll();
            TransactionCommitterDB transactionCommitterDB = new TransactionCommitterDB(DatabaseConnection.CurrentConnection);
            transactionCommitterDB.AddBusinessObject(bo);

            //---------------Execute Test ----------------------
            transactionCommitterDB.CommitTransaction();

            //---------------Test Result -----------------------
            mockRepos.VerifyAll();

        }
 public void TestInsertStatementExcludesAutoField_MySql()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     TestAutoInc.LoadClassDefWithAutoIncrementingID();
     TestAutoInc bo = new TestAutoInc();
     InsertStatementGenerator gen = CreateInsertStatementGenerator(bo, DatabaseConfig.MySql);
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var statementCol = gen.Generate();
     //---------------Test Result -----------------------
     var statement = statementCol.First();
     Assert.AreEqual("INSERT INTO `testautoinc` (`testfield`) VALUES (?Param0)", statement.Statement.ToString());
 }
 public void TestAutoIncrementObj()
 {
     ClassDef.ClassDefs.Clear();
     TestAutoInc.LoadClassDefWithAutoIncrementingID();
     TestAutoInc bo = new TestAutoInc();
     InsertStatementGenerator gen = new InsertStatementGenerator(bo, DatabaseConnection.CurrentConnection);
     var statementCol = gen.Generate();
     InsertSqlStatement statement = (InsertSqlStatement)statementCol.First();
     Assert.AreSame(typeof(SupportsAutoIncrementingFieldBO), statement.SupportsAutoIncrementingField.GetType());
 }
        public void Test_CommitTransaction_WithAutoIncrementBo_ShouldUseNumberGeneratorsInDatastore()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            IClassDef classDef = TestAutoInc.LoadClassDefWithAutoIncrementingID();

            DataStoreInMemory dataStore = MockRepository.GeneratePartialMock<DataStoreInMemory>();
            dataStore.Replay();

            int nextAutoIncNumber = TestUtil.GetRandomInt();

            dataStore.Stub(t => t.GetNextAutoIncrementingNumber(classDef)).Return(nextAutoIncNumber);

            ITransactionCommitter transactionCommitter = new TransactionCommitterInMemory(dataStore);
            
            TestAutoInc bo = new TestAutoInc();
            bo.SetPropertyValue("testfield", "testing 123");
            transactionCommitter.AddBusinessObject(bo);
            //---------------Assert Precondition----------------
            Assert.IsFalse(bo.TestAutoIncID.HasValue);
            Assert.AreSame(classDef, bo.ClassDef);
            Assert.IsTrue(bo.Props.HasAutoIncrementingField);
            //---------------Execute Test ----------------------
            transactionCommitter.CommitTransaction();
            //---------------Test Result -----------------------
            dataStore.AssertWasCalled(memory => memory.GetNextAutoIncrementingNumber(classDef));
            Assert.IsNotNull(bo.TestAutoIncID);
            Assert.AreEqual(nextAutoIncNumber, bo.TestAutoIncID);
            Assert.IsFalse(bo.Status.IsDirty);
        }