Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FB-279: Sync FeatureBoard API state back to ExternalState provider if registered #79

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
25 changes: 13 additions & 12 deletions libs/dotnet-sdk-test/FeatureBoardClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System.Text.Json.Nodes;
using Bogus;
using FeatureBoard.DotnetSdk.Helpers;
using FeatureBoard.DotnetSdk.Models;
using FeatureBoard.DotnetSdk.State;
using FeatureBoard.DotnetSdk.Test.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Bogus;
using Shouldly;
using FeatureBoard.DotnetSdk.Helpers;
using FeatureBoard.DotnetSdk.Models;
using FeatureBoard.DotnetSdk.State;

namespace FeatureBoard.DotnetSdk.Test;

Expand All @@ -18,6 +18,7 @@ public class FeatureBoardClientTests
public FeatureBoardClientTests()
{
Services.AddTransient(typeof(ILogger<>), typeof(NullLogger<>));
Services.AddTransient(typeof(Lazy<>));
Services.AddTransient<FeatureBoardClient<TestFeatures>>();

var audienceMock = Services.AddServiceMock<IAudienceProvider>((_, mock) =>
Expand All @@ -29,7 +30,7 @@ public FeatureBoardClientTests()
[Fact]
public void ItReturnsTheDefaultValueWhenNoValueIsFound()
{
Services.AddTransient<FeatureBoardStateSnapshot>(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration>(0)));
Services.AddTransient(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration>(0)));

var client = Services.BuildServiceProvider().GetRequiredService<FeatureBoardClient<TestFeatures>>();

Expand All @@ -44,7 +45,7 @@ public void ItReturnsTheDefaultValueFromFeatureBoardWhenNoAudienceIsFound()
{
var faker = new Faker();
var defaultFeatureValue = faker.Lorem.Sentence();
Services.AddTransient<FeatureBoardStateSnapshot>(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration>
Services.AddTransient(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration>
{
{
nameof(TestFeatures.StringFeature).ToFeatureBoardKey(), new FeatureConfiguration
Expand All @@ -66,7 +67,7 @@ public void ItReturnsTheAudienceValueFromFeatureBoardWhenAnAudienceIsFound()
{
var faker = new Faker();
var defaultAudienceValue = faker.Lorem.Paragraph();
Services.AddTransient<FeatureBoardStateSnapshot>(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration>
Services.AddTransient(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration>
{
{
nameof(TestFeatures.StringFeature).ToFeatureBoardKey(), new FeatureConfiguration
Expand Down Expand Up @@ -95,7 +96,7 @@ public void ItReturnsADecimal()
{
var faker = new Faker();
var defaultAudienceValue = faker.Random.Decimal();
Services.AddTransient<FeatureBoardStateSnapshot>(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration>
Services.AddTransient(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration>
{
{
nameof(TestFeatures.NumberFeature).ToFeatureBoardKey(), new FeatureConfiguration
Expand Down Expand Up @@ -125,7 +126,7 @@ public void ItReturnsABool()
{
var faker = new Faker();
var defaultAudienceValue = faker.Random.Bool();
Services.AddTransient<FeatureBoardStateSnapshot>(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration> {
Services.AddTransient(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration> {
{
nameof(TestFeatures.BoolFeature).ToFeatureBoardKey(), new FeatureConfiguration
{
Expand Down Expand Up @@ -153,7 +154,7 @@ public void ItReturnsAString()
{
var faker = new Faker();
var defaultAudienceValue = Guid.NewGuid().ToString();
Services.AddTransient<FeatureBoardStateSnapshot>(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration>
Services.AddTransient(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration>
{
{
nameof(TestFeatures.StringFeature).ToFeatureBoardKey(), new FeatureConfiguration
Expand Down Expand Up @@ -182,7 +183,7 @@ public void ItReturnsAnEnum()
{
var faker = new Faker();
var defaultAudienceValue = faker.PickRandom<TestEnum>();
Services.AddTransient<FeatureBoardStateSnapshot>(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration> {
Services.AddTransient(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration> {
{
nameof(TestFeatures.EnumFeature).ToFeatureBoardKey(), new FeatureConfiguration
{
Expand Down Expand Up @@ -211,7 +212,7 @@ public void ItLooksUpTheFeatureKeyWithFeatureKeyNameAttribute()
{
var faker = new Faker();
var defaultAudienceValue = Guid.NewGuid().ToString();
Services.AddTransient<FeatureBoardStateSnapshot>(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration> {
Services.AddTransient(_ => new FeatureBoardStateSnapshot(new Dictionary<string, FeatureConfiguration> {
{
"a-strange-name", new FeatureConfiguration
{
Expand Down
Loading