public void LoadFeatureSetFromType_Loads_Single_Feature_Into_FeatureSet() { var featureType = typeof(AspNetWebApiFeature); var projectTypeFeatureSet = FeatureSetLoader.LoadFeatureSetFromType(featureType); Assert.True(projectTypeFeatureSet.ConfiguredFeatures.Count == 0); Assert.True(projectTypeFeatureSet.CompiledFeatures.Count == 1); Assert.True(projectTypeFeatureSet.CompiledFeatures.First().GetType() == featureType); }
public void LoadDefaultFeatureSet_Loads_All_ProjectType_Features() { var defaultFeatureSet = FeatureSetLoader.LoadDefaultFeatureSet(); var projectTypeFeatureNames = defaultFeatureSet.CompiledFeatures.Select(f => f.Name); var expectedFeatureNames = new[] { nameof(AspNetMvcFeature), nameof(AspNetWebApiFeature), nameof(WebClassLibraryFeature) }; CollectionAssert.AreEquivalent(expectedFeatureNames, projectTypeFeatureNames); }
public FeatureDetector(IEnumerable <string> featureConfigPaths) { try { LoadedFeatureSet = FeatureSetLoader.LoadFeatureSetFromFeatureConfigFiles(featureConfigPaths); } catch (Exception e) { Logger.LogError(e, e.Message); } }
public FeatureDetector(string featureConfigPath) { try { LoadedFeatureSet = FeatureSetLoader.LoadFeatureSetFromFeatureConfigFile(featureConfigPath); } catch (Exception e) { Logger.LogError(e, e.Message); } }
public FeatureDetector(IEnumerable <FeatureConfig> featureConfigs) { try { LoadedFeatureSet = FeatureSetLoader.LoadFeatureSetFromFeatureConfigs(featureConfigs); } catch (Exception e) { var serializedConfig = JsonConvert.SerializeObject(featureConfigs); Logger.LogError(e, $"Failed to load features from feature config: {Environment.NewLine}{serializedConfig}"); } }
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}"); } }
public void FeatureDetector_Default_Constructor_Loads_All_ProjectType_Features() { var defaultFeatureDetector = new FeatureDetector(); var defaultFeatureSet = FeatureSetLoader.LoadDefaultFeatureSet(); var loadedFeatureNames = defaultFeatureDetector.LoadedFeatureSet.CompiledFeatures.Select(f => f.Name); var defaultFeatureNames = defaultFeatureSet.CompiledFeatures.Select(f => f.Name); var difference = defaultFeatureNames.Except(loadedFeatureNames); Assert.IsNotEmpty(defaultFeatureNames); Assert.IsNotEmpty(loadedFeatureNames); Assert.IsEmpty(difference); }
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); }
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); }
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); }); }
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 FeatureDetector() : this(FeatureSetLoader.LoadDefaultFeatureSet()) { }
public void LoadFeatureSetFromFeatureConfig_Loads_Features_Successfully_For_Well_Defined_Config() { var featureSet = FeatureSetLoader.LoadFeatureSetFromFeatureConfig(ParsedFeatureConfigSetupFixture.WellDefinedFeatureConfig); Assert.True(featureSet.AllFeatures.Any()); }