Esempio n. 1
0
        public async Task MapsEventDtoToSearchDocument()
        {
            var index = new Index(); //for proper use, this index should have been prepopulated
            var mockSearchIndexClient = new SearchIndexClientMock <SearchDocument>();

            var indexer = new AzureEventIndexer <TransferEvent, SearchDocument>(
                mockSearchIndexClient.SearchIndexClient, (tfr) => new SearchDocument(tfr.Log.TransactionHash, tfr.Log.LogIndex));

            var eventLog = TestData.Contracts.StandardContract.SampleTransferEventLog();

            await indexer.IndexAsync(eventLog);

            Assert.Single(mockSearchIndexClient.IndexedBatches);
            var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First();

            Assert.Equal(eventLog.Log.TransactionHash, firstIndexAction.Document.TransactionHash);
            Assert.Equal(eventLog.Log.LogIndex.Value.ToString(), firstIndexAction.Document.LogIndex);
        }
Esempio n. 2
0
        public async Task MapsEventDtoToGenericSearchDocument()
        {
            var indexDefinition       = new EventIndexDefinition <TransferEvent>();
            var index                 = indexDefinition.ToAzureIndex();
            var mockSearchIndexClient = new SearchIndexClientMock <GenericSearchDocument>();

            var indexer = new AzureEventIndexer <TransferEvent>(
                mockSearchIndexClient.SearchIndexClient, indexDefinition);

            var eventLog = TestData.Contracts.StandardContract.SampleTransferEventLog();

            await indexer.IndexAsync(eventLog);

            Assert.Single(mockSearchIndexClient.IndexedBatches);
            var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First();

            Assert.Equal(eventLog.Log.Key(), firstIndexAction.Document[PresetSearchFieldName.log_key.ToString()]);
        }