コード例 #1
0
        public async Task Save_ShouldNotCallStatementRepo_GivenNullStatementModel()
        {
            this.subject = CreateSubject();
            await this.subject.SaveAsync(It.IsAny <ApplicationDatabase>());

            this.mockStatementRepo.Verify(m => m.SaveAsync(It.IsAny <StatementModel>(), It.IsAny <bool>()), Times.Never);
        }
コード例 #2
0
        public void PopulateGroupByBucketCollection_ShouldReturnEmpty_GivenStatementModelNotLoaded()
        {
            this.subject = CreateSubject();
            IEnumerable <TransactionGroupedByBucket> result = this.subject.PopulateGroupByBucketCollection(true);

            Assert.IsFalse(result.Any());
        }
コード例 #3
0
 private void Arrange()
 {
     this.mockStatementRepo
     .Setup(m => m.LoadAsync(It.IsAny <string>(), It.IsAny <bool>()))
     .Returns(Task.FromResult(this.testData));
     this.subject = CreateSubject();
     this.subject.LoadAsync(this.testAppDb).Wait();
 }
コード例 #4
0
        private async Task Run(Factory <Task <ITransactionLogStorage> > storageFactory)
        {
            ITransactionManager tm = new Orleans.Transactions.TransactionManager(new TransactionLog(storageFactory), Options.Create(new TransactionsOptions()), NullLoggerFactory.Instance, NullTelemetryProducer.Instance, () => new NodeConfiguration(), LogMaintenanceInterval);
            await tm.StartAsync();

            ITransactionManagerService tms = new TransactionManagerService(tm);
            Stopwatch sw;
            int       success = 0;
            int       failed  = 0;

            sw = Stopwatch.StartNew();
            HashSet <long> transactionsInFlight  = new HashSet <long>();
            int            generatedTransactions = 0;

            while (generatedTransactions < TransactionsPerRun)
            {
                int generateCount = Math.Min(TransactionsPerRun - generatedTransactions, ConcurrentTransactionsTransactions - transactionsInFlight.Count);
                StartTransactionsResponse startResponse = await tms.StartTransactions(TransactionBatchTimeouts.Take(generateCount).ToList());

                List <TransactionInfo> newTransactions = startResponse.TransactionId
                                                         .Select(MakeTransactionInfo)
                                                         .ToList();
                generatedTransactions += newTransactions.Count;
                Console.WriteLine($"Generated {newTransactions.Count} Transactions.");
                transactionsInFlight.UnionWith(newTransactions.Select(ti => ti.TransactionId));
                do
                {
                    Tuple <int, int> results = await CommitAndCount(tms, newTransactions, transactionsInFlight);

                    success += results.Item1;
                    failed  += results.Item2;
                }while (transactionsInFlight.Count == ConcurrentTransactionsTransactions);
            }
            Console.WriteLine($"Generation Complete.");
            List <TransactionInfo> empty = new List <TransactionInfo>();

            while (transactionsInFlight.Count != 0)
            {
                Tuple <int, int> results = await CommitAndCount(tms, empty, transactionsInFlight);

                success += results.Item1;
                failed  += results.Item2;
            }
            sw.Stop();
            Console.WriteLine($"{generatedTransactions} Transactions performed in {sw.ElapsedMilliseconds}ms.  Succeeded: {success}, Failed: {failed}.");
            Console.WriteLine($"{success * 1000 / sw.ElapsedMilliseconds} Transactions/sec.");
            await tm.StopAsync();
        }
コード例 #5
0
 public void DetectDuplicateTransactions_ShouldReturnNull_GivenNullStatementModel()
 {
     this.subject = CreateSubject();
     Assert.IsNull(this.subject.DetectDuplicateTransactions());
 }