public void TestLoadNumberGenClassDef_ShouldAddClassDef_BUGFIX_ShouldBeThreadSafe()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, ClassDef.ClassDefs.Count);
            //---------------Execute Test ----------------------
            var exceptions = new List <Exception>();

            TestUtil.ExecuteInParallelThreads(2, () =>
            {
                try
                {
                    BOSequenceNumber.LoadNumberGenClassDef();
                }
                catch (Exception ex)
                {
                    exceptions.Add(ex);
                }
            });

            //---------------Test Result -----------------------
            if (exceptions.Count > 0)
            {
                Assert.Fail(exceptions[0].ToString());
            }
            Assert.AreEqual(1, ClassDef.ClassDefs.Count);
            Assert.IsNotNull(ClassDef.Get <BOSequenceNumber>());
        }
        private static void CleanupNumberGenerator()
        {
            BOSequenceNumber.LoadNumberGenClassDef();
            INumberGenerator numGen = new NumberGenerator("tmp");

            numGen.SetSequenceNumber(0);
        }
        public static void CleanUpContactPersonNumberGenerator_ForInMemory()
        {
            ContactPersonWithNumberGenerator.LoadDefaultClassDef();
            BOSequenceNumber.LoadNumberGenClassDef();
            INumberGenerator numGen = new NumberGenerator("GeneratedNumber");

            numGen.SetSequenceNumber(0);
        }
        public void TestLoadNumberGenClassDef_ShouldAddClassDef()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, ClassDef.ClassDefs.Count);
            //---------------Execute Test ----------------------
            BOSequenceNumber.LoadNumberGenClassDef();
            //---------------Test Result -----------------------
            Assert.AreEqual(1, ClassDef.ClassDefs.Count);
            Assert.IsNotNull(ClassDef.Get <BOSequenceNumber>());
        }
        public void TestSetSequenceNumber()
        {
            //---------------Set up test pack-------------------
            BOSequenceNumber.LoadNumberGenClassDef();
            NumberGenerator numGen = new NumberGenerator("tmp");

            numGen.NextNumber();
            numGen.Save();
            Assert.GreaterOrEqual(numGen.NextNumber(), 1);
            //---------------Execute Test ----------------------
            numGen.SetSequenceNumber(0);
            //---------------Test Result -----------------------
            numGen = new NumberGenerator("tmp");
            Assert.AreEqual(1, numGen.NextNumber());
            //---------------Tear Down -------------------------
        }
        public void TestDifferentTableNameGetSecondNumber_FromSeperateNumberGeneratorInstance_AfterUpdate()
        {
            //---------------Clean Up --------------------------
            BOSequenceNumber.LoadNumberGenClassDef("another_number_generator");
            NumberGenerator numGen = new NumberGenerator("tmp", "another_number_generator");

            numGen.SetSequenceNumber(0);
            //---------------Set up test pack-------------------
            //---------------Execute Test ----------------------
            numGen.NextNumber();
            numGen.Save();
            numGen = new NumberGenerator("tmp", "another_number_generator");
            long nextNum = numGen.NextNumber();

            //---------------Test Result -----------------------
            Assert.AreEqual(2, nextNum);
        }
        public void TestAcceptance_GenerateFirstNumber_NoSeed()
        {
            //Delete entry from database for the number type.
            BOSequenceNumber.LoadNumberGenClassDef();
            DatabaseConnection.CurrentConnection.ExecuteRawSql("Delete From NumberGenerator");
            //Create an instance of the number for a specific type of number (e.g. Invoice number)
            //---------------Set up test pack-------------------
            INumberGenerator numGen = new NumberGenerator("tmp");
            //---------------Execute Test ----------------------
            //get the next number for invoice number
            long sequenceNumber = numGen.NextNumber();

            //---------------Test Result -----------------------
            //test number should be one.
            Assert.AreEqual(1, sequenceNumber);
            //---------------Tear Down -------------------------
        }
        public void TestDifferentTableName()
        {
            //---------------Set up test pack-------------------
            //Delete entry from database for the number type.
            string tableName = "another_number_generator";

            BOSequenceNumber.LoadNumberGenClassDef(tableName);
            DatabaseConnection.CurrentConnection.ExecuteRawSql("Delete From " + tableName);
            //Create an instance of the number for a specific type of number (e.g. Invoice number)
            //---------------Set up test pack-------------------
            INumberGenerator numGen = new NumberGenerator("tmp", tableName);
            //---------------Execute Test ----------------------
            //get the next number for invoice number
            long sequenceNumber = numGen.NextNumber();

            //---------------Test Result -----------------------
            //test number should be one.
            Assert.AreEqual(1, sequenceNumber);
            //---------------Tear Down -------------------------
        }
        public void TestAcceptance_GenerateFirstNumber_SeedNonZero()
        {
            //---------------Set up test pack-------------------
            //Create an entry in the number generator table for entry type to seed with seed = 100.
            BOSequenceNumber.LoadNumberGenClassDef();
            INumberGenerator numGen     = new NumberGenerator("tmp");
            const int        seedNumber = 100;

            numGen.SetSequenceNumber(seedNumber);
            //Create an instance of the number for a specific type of number (e.g. Invoice number)
            numGen = new NumberGenerator("tmp");
            //---------------Execute Test ----------------------
            //get the next number for invoice number
            long nextNumber = numGen.NextNumber();

            //---------------Test Result -----------------------
            //test number should be 101.
            Assert.AreEqual(seedNumber + 1, nextNumber);
            //---------------Tear Down -------------------------
        }
Beispiel #10
0
        public void TestAcceptance_GenerateFirstNumber_SeedZero()
        {
            //---------------Clean Up --------------------------
            //Create an entry in the number generator table for entry type to seed.
            BOSequenceNumber.LoadNumberGenClassDef();
            const string numberType = "tmp";

            SetNumberGeneratorSeedZero(numberType);
            //---------------Set up test pack-------------------
            //Create an instance of the number for a specific type of number (e.g. Invoice number)
            INumberGenerator numGen = new NumberGenerator("tmp");

            //---------------Execute Test ----------------------
            //get the next number for invoice number
            long nextNum = numGen.NextNumber();

            //---------------Test Result -----------------------
            //test nextnumber should be one.
            Assert.AreEqual(1, nextNum);
            //---------------Tear Down -------------------------
        }
Beispiel #11
0
        public void TestAcceptance_GenerateSecondNumber_IncrementFirstNumber()
        {
            //---------------Set up test pack-------------------
            //Create an entry in the number generator table for entry type to seed with seed = 0.
            const string numberType = "tmp";

            BOSequenceNumber.LoadNumberGenClassDef();
            SetNumberGeneratorSeedZero(numberType);
            //Create an instance of the number for a specific type of number (e.g. Invoice number)
            INumberGenerator numGen = new NumberGenerator(numberType);

            //get the next number for invoice number
            numGen.NextNumber();
            //update to datasource

            //---------------Execute Test ----------------------
            //Get second number
            long nextNum = numGen.NextNumber();

            //---------------Test Result -----------------------
            //test number should be 2.
            Assert.AreEqual(2, nextNum);
        }