Ejemplo n.º 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");
    }
Ejemplo n.º 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...");
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 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...");
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 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...");
    }
Ejemplo n.º 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();
    }
Ejemplo n.º 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...");
    }