Esempio n. 1
0
        public List <FeatureClassInfo> GetFeatureClassesInfo()
        {
            var allClasses = _testAssembly.GetExportedTypes();

            var featureClassType = typeof(Feature);

            var featureClasses = allClasses.Where(c => c.GetTypeInfo().IsSubclassOf(featureClassType))
                                 .ToList();

            var featureClassesInfo = featureClasses.Select(fc => FeatureClassInfo.FromFeatureClassType(fc))
                                     .ToList();

            return(featureClassesInfo);
        }
        public static FeatureClass FromFeatureInstance(Feature featureInstance)
        {
            if (featureInstance == null)
            {
                throw new ArgumentNullException(nameof(featureInstance));
            }

            Type featureType     = featureInstance.GetType();
            var  featureFilePath = FeatureClassInfo.FromFeatureClassType(featureType).FeatureFilePath;

            var stepMethods = featureType.GetTypeInfo().GetMethods()
                              .Where(m => m.IsDefined(typeof(BaseStepDefinitionAttribute)))
                              .Select(m => StepMethodInfo.FromMethodInfo(m, featureInstance))
                              .ToList();

            return(new FeatureClass(featureFilePath, stepMethods));
        }
        public global::Gherkin.Ast.Feature Discover(Type featureClassType)
        {
            if (featureClassType == null)
            {
                throw new ArgumentNullException(nameof(featureClassType));
            }

            var fileName    = FeatureClassInfo.FromFeatureClassType(featureClassType).FeatureFilePath;
            var featureFile = _featureFileRepository.GetByFilePath(fileName);

            if (featureFile == null)
            {
                throw new System.IO.FileNotFoundException("Feature file not found.", fileName);
            }

            var feature = featureFile.GherkinDocument.Feature;

            return(feature);
        }