1- using System ;
1+ using System ;
22using System . Collections . Generic ;
33using System . IO ;
44using System . Linq ;
@@ -648,6 +648,24 @@ public void TestCannotCreateFlagsmithClientInRemoteEvaluationWithoutAPIKey()
648648 Assert . Equal ( "ValueError: environmentKey is required" , exception . Message ) ;
649649 }
650650
651+ [ Fact ]
652+ public void TestCannotCreateFlagsmithClientInLocalEvaluationWithoutServerAPIKey ( )
653+ {
654+ // When
655+ Action createFlagsmith = ( ) => new FlagsmithClient (
656+ environmentKey : "foobar" ,
657+ enableClientSideEvaluation : true
658+ ) ;
659+
660+ // Then
661+ var exception = Assert . Throws < Exception > ( ( ) => createFlagsmith ( ) ) ;
662+ Assert . Equal
663+ (
664+ "ValueError: In order to use local evaluation, please generate a server key in the environment settings page." ,
665+ exception . Message
666+ ) ;
667+ }
668+
651669 [ Fact ]
652670 /// <summary>
653671 /// Test that analytics data is consistent with concurrent calls to get flags.
@@ -685,7 +703,7 @@ public async Task TestAnalyticsDataConsistencyWithConcurrentCallsToGetFlags()
685703 featuresDictionary . TryAdd ( $ "Feature_{ i } ", 0 ) ;
686704 }
687705
688- // When
706+ // When
689707 var tasks = new Task [ numberOfThreads ] ;
690708
691709 // Create numberOfThreads threads.
@@ -696,13 +714,13 @@ public async Task TestAnalyticsDataConsistencyWithConcurrentCallsToGetFlags()
696714 // Prepare an array of feature names of length callsPerThread.
697715 for ( var j = 0 ; j < callsPerThread ; j ++ )
698716 {
699- // The feature names are randomly selected from the featuresDictionary and added to the
700- // list of features, which represents the features that have been evaluated.
717+ // The feature names are randomly selected from the featuresDictionary and added to the
718+ // list of features, which represents the features that have been evaluated.
701719 string featureName = $ "Feature_{ new Random ( ) . Next ( 1 , featuresDictionary . Count + 1 ) } ";
702720 features [ j ] = featureName ;
703721
704722 // The relevant key in the featuresDictionary is incremented to simulate an evaluation
705- // to track for that feature.
723+ // to track for that feature.
706724 featuresDictionary [ featureName ] ++ ;
707725 }
708726
0 commit comments