Skip to content
New issue

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

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

Already on GitHub? # to your account

Update the way to reference feature flag in ASP.NET test suite #404

Merged
merged 2 commits into from
Mar 20, 2024
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 @@ -36,12 +36,12 @@ public async Task Integrates()
services.AddMvcCore(o =>
{
DisableEndpointRouting(o);
o.Filters.AddForFeature<MvcFilter>(Enum.GetName(typeof(Features), Features.ConditionalFeature));
o.Filters.AddForFeature<MvcFilter>(Features.ConditionalFeature);
});
})
.Configure(app =>
{
app.UseForFeature(Enum.GetName(typeof(Features), Features.ConditionalFeature), a => a.Use(async (ctx, next) =>
app.UseForFeature(Features.ConditionalFeature, a => a.Use(async (ctx, next) =>
{
ctx.Response.Headers[nameof(RouterMiddleware)] = bool.TrueString;

Expand Down Expand Up @@ -102,7 +102,7 @@ public async Task GatesFeatures()

//
// Enable 1/2 features
testFeatureFilter.Callback = ctx => Task.FromResult(ctx.FeatureName == Enum.GetName(typeof(Features), Features.ConditionalFeature));
testFeatureFilter.Callback = ctx => Task.FromResult(ctx.FeatureName == Features.ConditionalFeature);

gateAllResponse = await testServer.CreateClient().GetAsync("gateAll");
gateAnyResponse = await testServer.CreateClient().GetAsync("gateAny");
Expand Down Expand Up @@ -158,7 +158,7 @@ public async Task GatesRazorPageFeatures()

//
// Enable 1/2 features
testFeatureFilter.Callback = ctx => Task.FromResult(ctx.FeatureName == Enum.GetName(typeof(Features), Features.ConditionalFeature));
testFeatureFilter.Callback = ctx => Task.FromResult(ctx.FeatureName == Features.ConditionalFeature);

gateAllResponse = await testServer.CreateClient().GetAsync("RazorTestAll");
gateAnyResponse = await testServer.CreateClient().GetAsync("RazorTestAny");
Expand Down
6 changes: 3 additions & 3 deletions tests/Tests.FeatureManagement.AspNetCore/Features.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
//
namespace Tests.FeatureManagement.AspNetCore
{
enum Features
static class Features
{
ConditionalFeature,
ConditionalFeature2
public const string ConditionalFeature = "ConditionalFeature";
public const string ConditionalFeature2 = "ConditionalFeature2";
}
}