コード例 #1
0
        public async Task IndexingTransferFunctions()
        {
            using (var azureSearchService = new AzureSearchService(AzureSearchServiceName, _azureSearchApiKey))
            {
                await azureSearchService.DeleteIndexAsync(AzureTransferIndexName);

                try
                {
                    using (var azureFunctionMessageIndexer =
                               await azureSearchService.CreateFunctionIndexer <TransferFunction>(
                                   indexName: AzureTransferIndexName))
                    {
                        var transferHandler =
                            new FunctionIndexTransactionHandler <TransferFunction>(azureFunctionMessageIndexer);

                        var web3            = new Web3.Web3(TestConfiguration.BlockchainUrls.Infura.Rinkeby);
                        var blockchainProxy = new BlockchainProxyService(web3);
                        var handlers        = new HandlerContainer {
                            TransactionHandler = transferHandler
                        };
                        var blockProcessor      = BlockProcessorFactory.Create(blockchainProxy, handlers);
                        var processingStrategy  = new ProcessingStrategy(blockProcessor);
                        var blockchainProcessor = new BlockchainProcessor(processingStrategy);

                        var blockRange = new BlockRange(3146684, 3146694);
                        await blockchainProcessor.ProcessAsync(blockRange);

                        await Task.Delay(TimeSpan.FromSeconds(5));

                        //ensure we have written the expected docs to the index
                        Assert.Equal(3, await azureFunctionMessageIndexer.DocumentCountAsync());
                    }
                }
                finally
                {
                    await azureSearchService.DeleteIndexAsync(AzureTransferIndexName);
                }
            }
        }