public void TestIntegration_UpdateAsRolledBack_ThenGetNextNumber_ShouldResetNumberToOriginalNumber()
        {
            //See GetNextNumber_WhenWasOne_ShouldReturnTwo Test for what would happen if the UpdateAsRolledBack Did not happen 
            //---------------Set up test pack-------------------
            var numberType = RandomValueGen.GetRandomString();

            //Create an instance of the number for a specific type of number (e.g. Invoice number)
            IDBNumberGenerator numGen = new DatabaseNumberGenerator(numberType, "numbergenerator", 0, "NumberType", "SequenceNumber");
            var updateTransaction = numGen.GetUpdateTransaction();
            //---------------Assert Precondition----------------
            Assert.AreEqual(1, numGen.GetNextNumberInt());
            //---------------Execute Test ----------------------
            updateTransaction.UpdateAsRolledBack();
            var nextNumberInt = numGen.GetNextNumberInt();
            //---------------Test Result -----------------------
            Assert.AreEqual(1, nextNumberInt);
        }
        public void TestIntegration_UpdateDB_WhenCurrentNumberIs2_ShouldUpdateDB()
        {
            //---------------Set up test pack-------------------
            var numberType = RandomValueGen.GetRandomString();

            //Create an instance of the number for a specific type of number (e.g. Invoice number)
            var dbTransactionCommitter = BORegistry.DataAccessor.CreateTransactionCommitter();
            IDBNumberGenerator numGen = new DatabaseNumberGenerator(numberType, "numbergenerator", 1, "NumberType", "SequenceNumber");
            var updateTransaction = numGen.GetUpdateTransaction() as ITransactionalDB;
            var currentNumber = numGen.GetNextNumberInt();
            //---------------Assert Precondition----------------
            Assert.IsInstanceOf<TransactionCommitterDB>(dbTransactionCommitter);
            Assert.IsNotNull(updateTransaction);
            Assert.AreEqual(2, currentNumber);
            //---------------Execute Test ----------------------
            dbTransactionCommitter.AddTransaction(updateTransaction);
            dbTransactionCommitter.CommitTransaction();
            //---------------Test Result -----------------------

            IDBNumberGenerator numGen2 = new DatabaseNumberGenerator(numberType, "numbergenerator", 1, "NumberType", "SequenceNumber");
            var nextNumberInt = numGen2.GetNextNumberInt();
            Assert.AreEqual(3, nextNumberInt);
        }
        public void TestIntegration_GetPersistSql_WhenNumberEQ2_ShouldReturnCorrectSQL()
        {
            //---------------Set up test pack-------------------
            var numberType = RandomValueGen.GetRandomString();

            //Create an instance of the number for a specific type of number (e.g. Invoice number)
            IDBNumberGenerator numGen = new DatabaseNumberGenerator(numberType, "numbergenerator", 0, "NumberType", "SequenceNumber");
            var updateTransaction = numGen.GetUpdateTransaction() as ITransactionalDB;
            numGen.GetNextNumberInt();
            var currentNumber = numGen.GetNextNumberInt();
            //---------------Assert Precondition----------------
            Assert.IsNotNull(updateTransaction);
            Assert.AreEqual(2, currentNumber);
            //---------------Execute Test ----------------------
            var sqlStatements = updateTransaction.GetPersistSql();
            //---------------Test Result -----------------------
            var sqlStatement = sqlStatements.FirstOrDefault();
            Assert.IsNotNull(sqlStatement);
            var stringStatement = sqlStatement.Statement.ToString();

            StringAssert.StartsWith(" update numbergenerator", stringStatement);
        }