33 lines
835 B
C#
33 lines
835 B
C#
using FluentAssertions;
|
|
using FreeCode.Features;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Xunit;
|
|
|
|
namespace FreeCode.Tests.Unit.Services;
|
|
|
|
public sealed class FeatureFlagServiceTests
|
|
{
|
|
[Fact]
|
|
public void IsEnabled_ForUnknownFlag_ReturnsFalse()
|
|
{
|
|
var sut = new FeatureFlagService(new ConfigurationBuilder().Build());
|
|
|
|
sut.IsEnabled("DOES_NOT_EXIST").Should().BeFalse();
|
|
}
|
|
|
|
[Fact]
|
|
public void IsEnabled_ForConfiguredFlag_ReturnsTrue()
|
|
{
|
|
var configuration = new ConfigurationBuilder()
|
|
.AddInMemoryCollection(new Dictionary<string, string?>
|
|
{
|
|
["FeatureFlags:BUDDY"] = "true"
|
|
})
|
|
.Build();
|
|
|
|
var sut = new FeatureFlagService(configuration);
|
|
|
|
sut.IsEnabled(FeatureFlags.Buddy).Should().BeTrue();
|
|
}
|
|
}
|