示例#1
0
 public EsIndexerBehavior(ClientFixture clFx, ITestOutputHelper output)
 {
     _clFx        = clFx;
     _output      = output;
     _clFx.Output = output;
     _indexer     = new EsIndexer <TestEntity>(new SingleEsClientProvider(_clFx.EsClient), null, (ElasticsearchOptions)null);
     _searcher    = new EsSearcher <TestEntity>(new SingleEsClientProvider(_clFx.EsClient), null, (ElasticsearchOptions)null);
 }
        public async Task InitializeAsync()
        {
            _index = await TmpIndexLife <TDoc> .CreateAsync(EsClient);

            Searcher = new EsSearcher <TDoc>(new SingleEsClientProvider(EsClient), null, (ElasticsearchOptions)null).ForIndex(_index.IndexName);
            Manager  = new EsManager(new SingleEsClientProvider(EsClient), (ElasticsearchOptions)null);
            Indexer  = new EsIndexer <TDoc>(new SingleEsClientProvider(EsClient), null, (ElasticsearchOptions)null).ForIndex(_index.IndexName);
        }
示例#3
0
        /// <summary>
        /// Creates index for the duration of function performing
        /// </summary>
        public async Task <TRes> UseTmpIndex <TRes>(Func <TestServices <TDoc>, Task <TRes> > func, string tmpIndexName = null)
        {
            await using var indexLife = await TmpIndexLife <TDoc> .CreateAsync(_client, tmpIndexName);

            var searcher = new EsSearcher <TDoc>(new SingleEsClientProvider(_client), null, (ElasticsearchOptions)null).ForIndex(indexLife.IndexName);
            var manager  = new EsManager(new SingleEsClientProvider(_client), (ElasticsearchOptions)null);
            var indexer  = new EsIndexer <TDoc>(new SingleEsClientProvider(_client), null, (ElasticsearchOptions)null).ForIndex(indexLife.IndexName);

            return(await func(new TestServices <TDoc>
            {
                IndexName = indexLife.IndexName,
                Indexer = indexer,
                Manager = manager,
                Searcher = searcher
            }));
        }