1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Threading ;
4
+ using System . Threading . Tasks ;
5
+ using Elastic . Xunit . XunitPlumbing ;
6
+ using FluentAssertions ;
7
+ using Nest ;
8
+ using Tests . Core . Extensions ;
9
+ using Tests . Core . ManagedElasticsearch . Clusters ;
10
+ using Tests . Framework . Integration ;
11
+ using Xunit ;
12
+
13
+ namespace Tests . Document . Multiple . BulkAll
14
+ {
15
+ public abstract class BulkAllApiTestsBase : IClusterFixture < IntrusiveOperationCluster > , IClassFixture < EndpointUsage >
16
+ {
17
+ protected BulkAllApiTestsBase ( IntrusiveOperationCluster cluster , EndpointUsage usage ) => this . Client = cluster . Client ;
18
+
19
+ protected class SmallObject
20
+ {
21
+ public int Id { get ; set ; }
22
+ }
23
+
24
+ protected IElasticClient Client { get ; }
25
+
26
+ protected static string CreateIndexName ( ) => $ "project-copy-{ Guid . NewGuid ( ) . ToString ( "N" ) . Substring ( 8 ) } ";
27
+
28
+ protected IEnumerable < SmallObject > CreateLazyStreamOfDocuments ( int count )
29
+ {
30
+ for ( var i = 0 ; i < count ; i ++ )
31
+ yield return new SmallObject ( ) { Id = i } ;
32
+ }
33
+
34
+ protected async Task CreateIndexAsync ( string indexName , int numberOfShards )
35
+ {
36
+ var result = await this . Client . CreateIndexAsync ( indexName , s => s
37
+ . Settings ( settings => settings
38
+ . NumberOfShards ( numberOfShards )
39
+ . NumberOfReplicas ( 0 )
40
+ )
41
+ ) ;
42
+ result . Should ( ) . NotBeNull ( ) ;
43
+ result . ShouldBeValid ( ) ;
44
+ }
45
+ protected static void OnError ( ref Exception ex , Exception e , EventWaitHandle handle )
46
+ {
47
+ ex = e ;
48
+ handle . Set ( ) ;
49
+ throw e ;
50
+ }
51
+ }
52
+ }
0 commit comments