1- using System ;
1+ using System ;
22using System . Collections . Generic ;
33using System . IO ;
44using System . Linq ;
@@ -523,6 +523,24 @@ public void TestCannotCreateFlagsmithClientInRemoteEvaluationWithoutAPIKey()
523523 Assert . Equal ( "ValueError: environmentKey is required" , exception . Message ) ;
524524 }
525525
526+ [ Fact ]
527+ public void TestCannotCreateFlagsmithClientInLocalEvaluationWithoutServerAPIKey ( )
528+ {
529+ // When
530+ Action createFlagsmith = ( ) => new FlagsmithClient (
531+ environmentKey : "foobar" ,
532+ enableClientSideEvaluation : true
533+ ) ;
534+
535+ // Then
536+ var exception = Assert . Throws < Exception > ( ( ) => createFlagsmith ( ) ) ;
537+ Assert . Equal
538+ (
539+ "ValueError: In order to use local evaluation, please generate a server key in the environment settings page." ,
540+ exception . Message
541+ ) ;
542+ }
543+
526544 [ Fact ]
527545 /// <summary>
528546 /// Test that analytics data is consistent with concurrent calls to get flags.
@@ -554,7 +572,7 @@ public async Task TestAnalyticsDataConsistencyWithConcurrentCallsToGetFlags()
554572 featuresDictionary . TryAdd ( $ "Feature_{ i } ", 0 ) ;
555573 }
556574
557- // When
575+ // When
558576 var tasks = new Task [ numberOfThreads ] ;
559577
560578 // Create numberOfThreads threads.
@@ -566,13 +584,13 @@ public async Task TestAnalyticsDataConsistencyWithConcurrentCallsToGetFlags()
566584 // Prepare an array of feature names of length callsPerThread.
567585 for ( int j = 0 ; j < callsPerThread ; j ++ )
568586 {
569- // The feature names are randomly selected from the featuresDictionary and added to the
570- // list of features, which represents the features that have been evaluated.
587+ // The feature names are randomly selected from the featuresDictionary and added to the
588+ // list of features, which represents the features that have been evaluated.
571589 string featureName = $ "Feature_{ new Random ( ) . Next ( 1 , featuresDictionary . Count + 1 ) } ";
572590 features [ j ] = featureName ;
573591
574592 // The relevant key in the featuresDictionary is incremented to simulate an evaluation
575- // to track for that feature.
593+ // to track for that feature.
576594 featuresDictionary [ featureName ] ++ ;
577595 }
578596
0 commit comments