<commit_before>﻿using System;
using FeatureToggle.Core;
using FeatureToggle.Providers;
using FeatureToggle.RavenDB.Providers;
using FeatureToggle.Toggles;
using Raven.Client.Document;
using Xunit;

namespace FeatureToggle.Integration.Tests
{    
// ReSharper disable InconsistentNaming
    public class BooleanRavenDBProviderShould
// ReSharper restore InconsistentNaming
    {

        public BooleanRavenDBProviderShould()
        {
            SetupTestData();
        }


        [Fact]
        public void ReadBooleanTrue()
        {
            var sut = new BooleanRavenDBProvider();

            var toggle = new MyRavenDBToggleTrue();

            Assert.True(sut.EvaluateBooleanToggleValue(toggle));
        }


        [Fact]
        public void ReadBooleanFalse()
        {
            var sut = new BooleanRavenDBProvider();

            var toggle = new MyRavenDBToggleFalse();

            Assert.False(sut.EvaluateBooleanToggleValue(toggle));
        }


        [Fact]
        public void ErrorWhenConnectionsStringNotInConfig()
        {
            var sut = new MissingConnectionStringToggle();

            var ex = Assert.Throws<ArgumentException>(() => sut.FeatureEnabled);

            Assert.Equal("Could not find connection string name: 'FeatureToggle.MissingConnectionStringToggle'", ex.Message);
        }


        [Fact]
        public void ErrorWhenToggleNotInDatabase()
        {
            var sut = new NotInDatabaseToggle();

            Assert.Throws<ToggleConfigurationError>(() => sut.FeatureEnabled);            
        }



        private class MyRavenDBToggleTrue : BooleanRavenDBFeatureToggle { }
        private class MyRavenDBToggleFalse : BooleanRavenDBFeatureToggle { }<commit_msg>Fixed false test failure when no RavenDB<commit_after>﻿using System;
using FeatureToggle.Core;
using FeatureToggle.Providers;
using FeatureToggle.RavenDB.Providers;
using FeatureToggle.Toggles;
using Raven.Client.Document;
using Xunit;

namespace FeatureToggle.Integration.Tests
{    
// ReSharper disable InconsistentNaming
    public class BooleanRavenDBProviderShould
// ReSharper restore InconsistentNaming
    {

        [Fact]
        public void ReadBooleanTrue()
        {
            SetupTestData();

            var sut = new BooleanRavenDBProvider();

            var toggle = new MyRavenDBToggleTrue();

            Assert.True(sut.EvaluateBooleanToggleValue(toggle));
        }


        [Fact]
        public void ReadBooleanFalse()
        {
            SetupTestData();

            var sut = new BooleanRavenDBProvider();

            var toggle = new MyRavenDBToggleFalse();

            Assert.False(sut.EvaluateBooleanToggleValue(toggle));
        }


        [Fact]
        public void ErrorWhenConnectionsStringNotInConfig()
        {
            var sut = new MissingConnectionStringToggle();

            var ex = Assert.Throws<ArgumentException>(() => sut.FeatureEnabled);

            Assert.Equal("Could not find connection string name: 'FeatureToggle.MissingConnectionStringToggle'", ex.Message);
        }


        [Fact]
        public void ErrorWhenToggleNotInDatabase()
        {
            SetupTestData();

            var sut = new NotInDatabaseToggle();

            Assert.Throws<ToggleConfigurationError>(() => sut.FeatureEnabled);            
        }



        private class MyRavenDBToggleTrue : BooleanRavenDBFeatureToggle { }
        private class MyRavenDBToggleFalse : BooleanRavenDBFeatureToggle { }
{'fraction_non_alphanumeric': 0.07873563218390804, 'fraction_numerical': 0.0, 'mean_word_length': 2.460238568588469, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3318023', 'n_tokens_mistral': 912, 'n_tokens_neox': 847, 'n_words': 190}