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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static IServiceCollection AddOpenFeature(this IServiceCollection services
var builder = new OpenFeatureBuilder(services);
configure(builder);

builder.Services.Configure<OpenFeatureOptions>(c => { }); // Ensures IOptions<OpenFeatureOptions> is available even when no providers are configured.
builder.Services.AddHostedService<HostedFeatureLifecycleService>();

// If a default provider is specified without additional providers,
Expand All @@ -50,7 +51,7 @@ public static IServiceCollection AddOpenFeature(this IServiceCollection services
options.DefaultNameSelector = provider =>
{
var options = provider.GetRequiredService<IOptions<OpenFeatureOptions>>().Value;
return options.ProviderNames.First();
return options.ProviderNames.FirstOrDefault();
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,16 @@ public void AddOpenFeature_WithNamedDefaultProvider_InvokesAddPolicyName()
var otherClient = serviceProvider.GetService<IFeatureClient>();
Assert.NotNull(otherClient);
}

[Fact]
public void AddOpenFeature_WithNoProvider_CanResolveFeatureClient()
{
// Act
_systemUnderTest.AddOpenFeature(builder => { });

// Assert
using var serviceProvider = _systemUnderTest.BuildServiceProvider();
var client = serviceProvider.GetService<IFeatureClient>();
Assert.NotNull(client);
}
}