Exemple #1
0
 public FeatureDetector(FeatureConfig featureConfig)
     : this(new [] { featureConfig })
 {
     try
     {
         LoadedFeatureSet = FeatureSetLoader.LoadFeatureSetFromFeatureConfig(featureConfig);
     }
     catch (Exception e)
     {
         var serializedConfig = JsonConvert.SerializeObject(featureConfig);
         Logger.LogError(e, $"Failed to load features from feature config: {Environment.NewLine}{serializedConfig}");
     }
 }
Exemple #2
0
        public void Add_Puts_Features_In_Proper_Collections()
        {
            var validFeatureSet   = FeatureSetLoader.LoadFeatureSetFromFeatureConfig(ParsedFeatureConfigSetupFixture.WellDefinedFeatureConfig);
            var compiledFeature   = validFeatureSet.CompiledFeatures.First();
            var configuredFeature = validFeatureSet.ConfiguredFeatures.First();

            var testFeatureSet = new FeatureSet();

            testFeatureSet.Add(compiledFeature);
            testFeatureSet.Add(configuredFeature);

            Assert.True(testFeatureSet.CompiledFeatures.First().Name == compiledFeature.Name);
            Assert.True(testFeatureSet.ConfiguredFeatures.First().Name == configuredFeature.Name);
        }
Exemple #3
0
        public void UnionWith_Puts_Features_In_Proper_Collections()
        {
            var validFeatureSet   = FeatureSetLoader.LoadFeatureSetFromFeatureConfig(ParsedFeatureConfigSetupFixture.WellDefinedFeatureConfig);
            var compiledFeature   = validFeatureSet.CompiledFeatures.First();
            var configuredFeature = validFeatureSet.ConfiguredFeatures.First();

            var featureSetToAdd = new FeatureSet();

            featureSetToAdd.Add(compiledFeature);
            featureSetToAdd.Add(configuredFeature);

            var featureSet = new FeatureSet();

            featureSet.UnionWith(featureSetToAdd);

            Assert.True(featureSet.CompiledFeatures.First().Name == compiledFeature.Name);
            Assert.True(featureSet.ConfiguredFeatures.First().Name == configuredFeature.Name);
        }
Exemple #4
0
        public void Add_Many_Features_Catches_Exceptions_If_Features_Have_Same_Name()
        {
            var validFeatureSet   = FeatureSetLoader.LoadFeatureSetFromFeatureConfig(ParsedFeatureConfigSetupFixture.WellDefinedFeatureConfig);
            var compiledFeature   = validFeatureSet.CompiledFeatures.First();
            var configuredFeature = validFeatureSet.ConfiguredFeatures.First();

            configuredFeature.Name = compiledFeature.Name;

            var compiledFeatures = new List <CompiledFeature> {
                compiledFeature
            };

            Assert.DoesNotThrow(() =>
            {
                var testFeatureSet = new FeatureSet();
                testFeatureSet.Add(configuredFeature);
                testFeatureSet.Add(compiledFeatures);
            });
        }
Exemple #5
0
        public void Add_Throws_Exception_If_CompiledFeature_And_ConfiguredFeature_Have_Same_Name()
        {
            var validFeatureSet   = FeatureSetLoader.LoadFeatureSetFromFeatureConfig(ParsedFeatureConfigSetupFixture.WellDefinedFeatureConfig);
            var compiledFeature   = validFeatureSet.CompiledFeatures.First();
            var configuredFeature = validFeatureSet.ConfiguredFeatures.First();

            configuredFeature.Name = compiledFeature.Name;

            Assert.Throws <ArgumentException>(() =>
            {
                var testFeatureSet = new FeatureSet();
                testFeatureSet.Add(compiledFeature);
                testFeatureSet.Add(configuredFeature);
            });

            Assert.Throws <ArgumentException>(() =>
            {
                var testFeatureSet = new FeatureSet();
                testFeatureSet.Add(configuredFeature);
                testFeatureSet.Add(compiledFeature);
            });
        }
        public void LoadFeatureSetFromFeatureConfig_Loads_Features_Successfully_For_Well_Defined_Config()
        {
            var featureSet = FeatureSetLoader.LoadFeatureSetFromFeatureConfig(ParsedFeatureConfigSetupFixture.WellDefinedFeatureConfig);

            Assert.True(featureSet.AllFeatures.Any());
        }