Ejemplo n.º 1
0
        public void RunSequencesPerformance()
        {
            var repository = new CommerceRepositoryImpl("VirtoCommerce");
            var sequence = new SequenceUniqueNumberGeneratorServiceImpl(() => repository);

            for (var i = 1; i < SequenceUniqueNumberGeneratorServiceImpl.SequenceReservationRange; i++)
            {
                var result = sequence.GenerateNumber("CO{0:yyMMdd}-{1:D5}");
                Debug.WriteLine(result);

                //This would fail if any duplicate generated
                Assert.IsFalse(GlobalNumbers.ContainsKey(result));
                GlobalNumbers.Add(result, result);

                const string sql = "INSERT UniqueSequence VALUES(@p0);";
                //This would fail if any duplicate generated beause we use primary key
                var sqlResult = repository.Database.ExecuteSqlCommand(sql, result);
                Assert.AreEqual(1, sqlResult);
            }
        }
Ejemplo n.º 2
0
        public void RunSequencesPerformance()
        {
            var repository = new CommerceRepositoryImpl("VirtoCommerce");
            var sequence   = new SequenceUniqueNumberGeneratorServiceImpl(() => repository);

            for (var i = 1; i < SequenceUniqueNumberGeneratorServiceImpl.SequenceReservationRange; i++)
            {
                var result = sequence.GenerateNumber("CO{0:yyMMdd}-{1:D5}");
                Debug.WriteLine(result);

                //This would fail if any duplicate generated
                Assert.IsFalse(GlobalNumbers.ContainsKey(result));
                GlobalNumbers.Add(result, result);

                const string sql = "INSERT UniqueSequence VALUES(@p0);";
                //This would fail if any duplicate generated beause we use primary key
                var sqlResult = repository.Database.ExecuteSqlCommand(sql, result);
                Assert.AreEqual(1, sqlResult);
            }
        }
Ejemplo n.º 3
0
        public void Can_run_sequences_performance()
        {
            var repository = GetRepository();
            var sequence   = new SequenceUniqueNumberGeneratorServiceImpl(() => repository);

            for (var i = 1; i < SequenceUniqueNumberGeneratorServiceImpl.SequenceReservationRange; i++)
            {
                var result = sequence.GenerateNumber("CO{0:yyMMdd}-{1:D5}");
                Debug.WriteLine(result);

                //This would fail if any duplicate generated
                Assert.False(GlobalNumbers.ContainsKey(result));
                GlobalNumbers.Add(result, result);

                /* don't need second checks here
                 * const string sql = "INSERT UniqueSequence VALUES(@p0);";
                 *
                 * //This would fail if any duplicate generated beause we use primary key
                 * var sqlResult = repository.Database.ExecuteSqlCommand(sql, result);
                 * Assert.Equal(1, sqlResult);
                 */
            }
        }