Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Flagsmith.Client.Test/Fixtures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Flagsmith.FlagsmithClientTest
{
internal class Fixtures
{
public static string ApiKey => "ser.test_key";
public static string ApiKey => "test_key";
public static string ApiUrl => "http://test_url/";
public static AnalyticsProcessorTest GetAnalyticalProcessorTest() => new(new HttpClient(), ApiKey, ApiUrl);
public static JObject JsonObject = JObject.Parse(@"{
Expand Down
28 changes: 5 additions & 23 deletions Flagsmith.Client.Test/FlagsmithTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -523,24 +523,6 @@ public void TestCannotCreateFlagsmithClientInRemoteEvaluationWithoutAPIKey()
Assert.Equal("ValueError: environmentKey is required", exception.Message);
}

[Fact]
public void TestCannotCreateFlagsmithClientInLocalEvaluationWithoutServerAPIKey()
{
// When
Action createFlagsmith = () => new FlagsmithClient(
environmentKey: "foobar",
enableClientSideEvaluation: true
);

// Then
var exception = Assert.Throws<Exception>(() => createFlagsmith());
Assert.Equal
(
"ValueError: In order to use local evaluation, please generate a server key in the environment settings page.",
exception.Message
);
}

[Fact]
/// <summary>
/// Test that analytics data is consistent with concurrent calls to get flags.
Expand Down Expand Up @@ -572,7 +554,7 @@ public async Task TestAnalyticsDataConsistencyWithConcurrentCallsToGetFlags()
featuresDictionary.TryAdd($"Feature_{i}", 0);
}

// When
// When
var tasks = new Task[numberOfThreads];

// Create numberOfThreads threads.
Expand All @@ -584,13 +566,13 @@ public async Task TestAnalyticsDataConsistencyWithConcurrentCallsToGetFlags()
// Prepare an array of feature names of length callsPerThread.
for (int j = 0; j < callsPerThread; j++)
{
// The feature names are randomly selected from the featuresDictionary and added to the
// list of features, which represents the features that have been evaluated.
// The feature names are randomly selected from the featuresDictionary and added to the
// list of features, which represents the features that have been evaluated.
string featureName = $"Feature_{new Random().Next(1, featuresDictionary.Count + 1)}";
features[j] = featureName;

// The relevant key in the featuresDictionary is incremented to simulate an evaluation
// to track for that feature.
// to track for that feature.
featuresDictionary[featureName]++;
}

Expand Down
6 changes: 3 additions & 3 deletions Flagsmith.FlagsmithClient/FlagsmithClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ public FlagsmithClient(
{
if (!EnvironmentKey!.StartsWith("ser."))
{
throw new Exception(
"ValueError: In order to use local evaluation, please generate a server key in the environment settings page."
Console.WriteLine(
"In order to use local evaluation, please generate a server key in the environment settings page."
);
}

Expand Down Expand Up @@ -399,4 +399,4 @@ private IFlags GetIdentityFlagsFromDocument(string identifier, List<ITrait>? tra

~FlagsmithClient() => _pollingManager?.StopPoll();
}
}
}
Loading