public async Task MapsSourceToSearchDocument() { var mockElasticClient = new MockElasticClient(); var mappedSearchDocument = new SearchDocument(); var indexer = new ElasticIndexer <Source, SearchDocument>("my-index", mockElasticClient.ElasticClient, (tfr) => mappedSearchDocument); var source = new Source(); await indexer.IndexAsync(source); Assert.Single(mockElasticClient.BulkRequests); var indexedDoc = mockElasticClient.GetFirstBulkOperation().GetBody() as SearchDocument; Assert.Same(mappedSearchDocument, indexedDoc); }
public async Task MapsSourceToSearchDocument() { var index = new Index(); //for proper use, this index should have been prepopulated var mockSearchIndexClient = new SearchIndexClientMock <SearchDocument>(); var mappedSearchDocument = new SearchDocument(); var indexer = new AzureIndexer <Source, SearchDocument>( mockSearchIndexClient.SearchIndexClient, (tfr) => mappedSearchDocument); var source = new Source(); await indexer.IndexAsync(source); Assert.Single(mockSearchIndexClient.IndexedBatches); var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First(); Assert.Same(mappedSearchDocument, firstIndexAction.Document); }