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()]); }