示例#1
0
    public async Task GetValueShouldReturnStringValue()
    {
        // Arrange
        InitializeFeaturesData();
        var featuresService = new FeaturesService(_db, new Settings());

        // Act
        string value = await featuresService.GetValue <string>("Theme");

        // Assert
        value.ShouldBe("light");
    }
示例#2
0
    public async Task GetValueShouldFailIfMismatchTypeForStringValue()
    {
        // Arrange
        InitializeFeaturesData();
        var featuresService = new FeaturesService(_db, new Settings());

        // Act
        var exception = await featuresService.GetValue <decimal>("Theme").ShouldThrowAsync <Exception>();

        // Assert
        exception.Message.ShouldBe("The feature Theme is a string feature...");
    }
示例#3
0
    public async Task GetValueShouldReturnDecimalValue()
    {
        // Arrange
        InitializeFeaturesData();
        var featuresService = new FeaturesService(_db, new Settings());

        // Act
        decimal value = await featuresService.GetValue <decimal>("TaxPercent");

        // Assert
        value.ShouldBe(12.5m);
    }
示例#4
0
    public async Task GetValueShouldFailIfMismatchTypeForIntValue()
    {
        // Arrange
        InitializeFeaturesData();
        var featuresService = new FeaturesService(_db, new Settings());

        // Act
        var exception = await featuresService.GetValue <bool>("Delay").ShouldThrowAsync <Exception>();

        // Assert
        exception.Message.ShouldBe("The feature Delay is an integer feature...");
    }
示例#5
0
    public async Task GetValueShouldReturnIntValue()
    {
        // Arrange
        InitializeFeaturesData();
        var featuresService = new FeaturesService(_db, new Settings());

        // Act
        int value = await featuresService.GetValue <int>("Delay");

        // Assert
        value.ShouldBe(1000);
    }
示例#6
0
    public async Task GetValueShouldFailIfMismatchTypeForBooleanValue()
    {
        // Arrange
        InitializeFeaturesData();
        var featuresService = new FeaturesService(_db, new Settings());

        // Act
        var exception = await featuresService.GetValue <string>("Beta").ShouldThrowAsync <Exception>();

        // Assert
        exception.Message.ShouldBe("The feature Beta is a boolean feature...");
    }
示例#7
0
    public async Task GetValueShouldReturnBooleanValue()
    {
        // Arrange
        InitializeFeaturesData();
        var featuresService = new FeaturesService(_db, new Settings());

        // Act
        bool value = await featuresService.GetValue <bool>("Beta");

        // Assert
        value.ShouldBeTrue();
    }
示例#8
0
    public async Task GetValueShouldFailIfNoFeatureFound()
    {
        // Arrange
        InitializeFeaturesData();
        var featuresService = new FeaturesService(_db, new Settings());

        string featureName = "X";

        // Act
        var exception = await featuresService.GetValue <string>(featureName).ShouldThrowAsync <Exception>();

        // Assert
        exception.Message.ShouldBe($"The feature {featureName} does not exist...");
    }