-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flagsmith improvements and start creating tests
- Loading branch information
1 parent
d1fb7eb
commit 1a355ab
Showing
7 changed files
with
135 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
src/OpenFeature.Contrib.Providers.Flagsmith/Exceptions/FlagsmithProviderException .cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
test/OpenFeature.Contrib.Providers.Flagsmith.Test/FlagsmithProviderTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using Xunit; | ||
using System; | ||
using Flagsmith; | ||
using System.Net.Http; | ||
|
||
namespace OpenFeature.Contrib.Providers.Flagsmith.Test | ||
{ | ||
public class UnitTestFlagsmithProvider | ||
{ | ||
private static FlagsmithConfiguration GetDefaultFlagsmithConfiguration() => new () | ||
{ | ||
ApiUrl = "https://edge.api.flagsmith.com/api/v1/", | ||
EnvironmentKey = string.Empty, | ||
EnableClientSideEvaluation = false, | ||
EnvironmentRefreshIntervalSeconds = 60, | ||
EnableAnalytics = false, | ||
Retries = 1 | ||
}; | ||
[Fact] | ||
public void CreateFlagmithProvider_WithValidCredetials_CreatesInstanceSuccessfully() | ||
{ | ||
// Arrange | ||
var config = GetDefaultFlagsmithConfiguration(); | ||
|
||
// Act | ||
var flagsmithProvider = new FlagsmithProvider(config); | ||
|
||
|
||
// Assert | ||
Assert.NotNull(flagsmithProvider._flagsmithClient); | ||
} | ||
|
||
[Fact] | ||
public void CreateFlagmithProvider_WithValidCredetialsAndCustomHttpClient_CreatesInstanceSuccessfully() | ||
{ | ||
// Arrange | ||
var config = GetDefaultFlagsmithConfiguration(); | ||
using var httpClient = new HttpClient(); | ||
// Act | ||
var flagsmithProvider = new FlagsmithProvider(config, httpClient); | ||
|
||
|
||
// Assert | ||
Assert.NotNull(flagsmithProvider._flagsmithClient); | ||
} | ||
|
||
[Fact] | ||
public void CreateFlagmithProvider_WithCustomFlagsmithClient_CreatesInstanceSuccessfully() | ||
{ | ||
// Arrange | ||
var flagsmithClient = new FlagsmithClient(GetDefaultFlagsmithConfiguration()); | ||
// Act | ||
var flagsmithProvider = new FlagsmithProvider(flagsmithClient); | ||
|
||
|
||
// Assert | ||
Assert.NotNull(flagsmithProvider._flagsmithClient); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ture.Contrib.Providers.Flagsmith.Test/OpenFeature.Contrib.Providers.Flagsmith.Test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\OpenFeature.Contrib.Providers.Flagsmith\OpenFeature.Contrib.Providers.Flagsmith.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Flagsmith" Version="5.1.0" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
</Project> |