예제 #1
0
        public Task CreateBatchAsyncTest()
        {
            //  Stage - number of for loops to complete & collectin of TransactionModels
            var rounds     = 10000;
            var collection = new List <TransactionModel>();

            for (int i = 0; i < rounds; i++)
            {
                // instantiate a new TransactionModel
                var transaction = new TransactionModel(MY_BLOCKCHAIN, ISSUE_MORE, $"{Guid.NewGuid()}")
                {
                    CreatedBy      = nameof(CreateAsyncTest),
                    LastModifiedBy = nameof(CreateAsyncTest)
                };
                collection.Add(transaction);
            }

            /* .SaveChangesAsync() is called automatically within the contract */
            /* We don't need to call .SaveChangesAsync() again here for any reason */

            // Act & Assert - create a collection of TransactionModels in local storage
            //                optional parameter of batchSize defaults to 1000
            //                e.g. Pass 20,000 records to the method but only commit 1000 at a time
            Assert.DoesNotThrowAsync(async() => await _contract.CreateBatchAsync(collection, BatchSize.OneThousand));

            return(Task.CompletedTask);
        }