@@ -8,14 +8,6 @@ namespace Tests.Configuration
88 public class YamlConfiguration : TestConfigurationBase
99 {
1010 private readonly Dictionary < string , string > _config ;
11- public sealed override bool TestAgainstAlreadyRunningElasticsearch { get ; protected set ; } = true ;
12- public sealed override string ElasticsearchVersion { get ; protected set ; }
13- public sealed override bool ForceReseed { get ; protected set ; } = true ;
14- public sealed override TestMode Mode { get ; protected set ; } = TestMode . Unit ;
15- public sealed override string ClusterFilter { get ; protected set ; }
16- public sealed override string TestFilter { get ; protected set ; }
17- public sealed override int Seed { get ; protected set ; }
18- public sealed override bool ShowElasticsearchOutputAfterStarted { get ; protected set ; }
1911
2012 public YamlConfiguration ( string configurationFile )
2113 {
@@ -25,32 +17,43 @@ public YamlConfiguration(string configurationFile)
2517 . Where ( l => ! l . Trim ( ) . StartsWith ( "#" ) && ! string . IsNullOrWhiteSpace ( l ) )
2618 . ToDictionary ( ConfigName , ConfigValue ) ;
2719
28- this . Mode = GetTestMode ( _config [ "mode" ] ) ;
20+ Mode = GetTestMode ( _config [ "mode" ] ) ;
2921 var version = _config [ "elasticsearch_version" ] ;
30- this . ElasticsearchVersion = string . IsNullOrWhiteSpace ( version ) ? DefaultVersion : version ;
31- this . ForceReseed = this . BoolConfig ( "force_reseed" , false ) ;
32- this . TestAgainstAlreadyRunningElasticsearch = this . BoolConfig ( "test_against_already_running_elasticsearch" , false ) ;
33- this . ShowElasticsearchOutputAfterStarted = this . BoolConfig ( "elasticsearch_out_after_started" , false ) ;
34- this . ClusterFilter = _config . ContainsKey ( "cluster_filter" ) ? _config [ "cluster_filter" ] : null ;
35- this . TestFilter = _config . ContainsKey ( "test_filter" ) ? _config [ "test_filter" ] : null ;
22+ ElasticsearchVersion = string . IsNullOrWhiteSpace ( version ) ? DefaultVersion : version ;
23+ ForceReseed = BoolConfig ( "force_reseed" , false ) ;
24+ TestAgainstAlreadyRunningElasticsearch = BoolConfig ( "test_against_already_running_elasticsearch" , false ) ;
25+ ShowElasticsearchOutputAfterStarted = BoolConfig ( "elasticsearch_out_after_started" , false ) ;
26+ ClusterFilter = _config . ContainsKey ( "cluster_filter" ) ? _config [ "cluster_filter" ] : null ;
27+ TestFilter = _config . ContainsKey ( "test_filter" ) ? _config [ "test_filter" ] : null ;
3628
3729 var newRandom = new Random ( ) . Next ( 1 , 100000 ) ;
38- this . Seed = _config . TryGetValue ( "seed" , out var seed ) ? int . Parse ( seed ) : newRandom ;
39- var randomizer = new Random ( this . Seed ) ;
40- this . Random = new RandomConfiguration
30+ Seed = _config . TryGetValue ( "seed" , out var seed ) ? int . Parse ( seed ) : newRandom ;
31+ var randomizer = new Random ( Seed ) ;
32+ Random = new RandomConfiguration
4133 {
42- SourceSerializer = this . RandomBool ( "source_serializer" , randomizer ) ,
43- TypedKeys = this . RandomBool ( "typed_keys" , randomizer ) ,
34+ SourceSerializer = RandomBool ( "source_serializer" , randomizer ) ,
35+ TypedKeys = RandomBool ( "typed_keys" , randomizer ) ,
4436 } ;
4537 }
4638
39+ public sealed override string ClusterFilter { get ; protected set ; }
40+ public sealed override string ElasticsearchVersion { get ; protected set ; }
41+ public sealed override bool ForceReseed { get ; protected set ; } = true ;
42+ public sealed override TestMode Mode { get ; protected set ; } = TestMode . Unit ;
43+ public sealed override int Seed { get ; protected set ; }
44+ public sealed override bool ShowElasticsearchOutputAfterStarted { get ; protected set ; }
45+ public sealed override bool TestAgainstAlreadyRunningElasticsearch { get ; protected set ; } = true ;
46+ public sealed override string TestFilter { get ; protected set ; }
47+
4748 private bool BoolConfig ( string key , bool @default ) => _config . TryGetValue ( key , out var v ) ? bool . Parse ( v ) : @default ;
4849
4950 private bool RandomBool ( string key , Random random ) =>
5051 _config . TryGetValue ( $ "random_{ key } ", out var v ) ? bool . Parse ( v ) : random . NextDouble ( ) >= 0.5 ;
5152
5253 private static string ConfigName ( string configLine ) => Parse ( configLine , 0 ) ;
54+
5355 private static string ConfigValue ( string configLine ) => Parse ( configLine , 1 ) ;
56+
5457 private static string Parse ( string configLine , int index ) => configLine . Split ( ':' ) [ index ] . Trim ( ' ' ) ;
5558
5659 private static TestMode GetTestMode ( string mode )
0 commit comments