public async Task MapsTransactionToSearchDocument() { var mockElasticClient = new MockElasticClient(); var indexer = new ElasticTransactionReceiptVOIndexer <SearchDocument>("my-index", mockElasticClient.ElasticClient, (tx) => new SearchDocument(tx)); TransactionReceiptVO transaction = IndexerTestData.CreateSampleTransaction(); await indexer.IndexAsync(transaction); Assert.Single(mockElasticClient.BulkRequests); var indexedDocument = mockElasticClient.GetFirstBulkOperation().GetBody() as SearchDocument; //check mapping Assert.Same(transaction, indexedDocument.TransactionReceiptVO); }
public async Task MapsTransactionToGenericSearchDocument() { var indexDefinition = new TransactionReceiptVOIndexDefinition("my-transactions"); var mockElasticClient = new MockElasticClient(); var indexer = new ElasticTransactionReceiptVOIndexer("my-index", mockElasticClient.ElasticClient, indexDefinition); TransactionReceiptVO transaction = IndexerTestData.CreateSampleTransaction(); await indexer.IndexAsync(transaction); Assert.Single(mockElasticClient.BulkRequests); var indexedDoc = mockElasticClient.GetFirstBulkOperation().GetBody() as GenericSearchDocument; //check generic mapping Assert.Equal(transaction.Transaction.BlockNumber.ToString(), indexedDoc[PresetSearchFieldName.tx_block_number.ToString()]); }
public async Task MapsTransactionToSearchDocument() { var index = new Index(); var mockSearchIndexClient = new SearchIndexClientMock <SearchDocument>(); var indexer = new AzureTransactionReceiptVOIndexer <SearchDocument>( mockSearchIndexClient.SearchIndexClient, (tx) => new SearchDocument(tx)); TransactionReceiptVO transaction = IndexerTestData.CreateSampleTransaction(); await indexer.IndexAsync(transaction); Assert.Single(mockSearchIndexClient.IndexedBatches); var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First(); var document = firstIndexAction.Document; //check mapping Assert.Same(transaction, document.TransactionReceiptVO); }
public async Task MapsTransactionToGenericSearchDocument() { var indexDefinition = new TransactionReceiptVOIndexDefinition("my-transactions"); var index = indexDefinition.ToAzureIndex(); var mockSearchIndexClient = new SearchIndexClientMock <GenericSearchDocument>(); var indexer = new AzureTransactionReceiptVOIndexer( mockSearchIndexClient.SearchIndexClient, indexDefinition); TransactionReceiptVO transaction = IndexerTestData.CreateSampleTransaction(); await indexer.IndexAsync(transaction); Assert.Single(mockSearchIndexClient.IndexedBatches); var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First(); var document = firstIndexAction.Document; //check generic mapping Assert.Equal(transaction.Transaction.BlockNumber.ToString(), document[PresetSearchFieldName.tx_block_number.ToString()]); }