Пример #1
0
 static CodeFunction CodeFunctionForUnimplemented(this Project project, Step Step)
 {
     return(project.Classes()
            .Where(x => x.Name == Step.Feature.Name)
            .SelectMany(x => x.Functions())
            .FirstOrDefault(x => x.EqualsTo(Step)));
 }
Пример #2
0
        // needs to b run from IDE
        public void should_load_Settings()
        {
            var Dte = Marshal.GetActiveObject("VisualStudio.DTE") as DTE;

            var DteProject = Dte.SelectedItems.Item(1).ProjectItem.ContainingProject;

            string fullPath       = DteProject.Properties.Item("FullPath").Value.ToString();
            string outputPath     = DteProject.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString();
            string outputDir      = Path.Combine(fullPath, outputPath);
            string outputFileName = DteProject.Properties.Item("OutputFileName").Value.ToString();
            string assemblyPath   = Path.Combine(outputDir, outputFileName);

            DteProject.Name.ShouldBe("Features");


            (assemblyPath).ShouldNotBeNull();

            var Project = new Project {
                DTEProject = DteProject
            };

            Project.Load();

            Settings.XUnit.Name.ShouldBe("MsTest");
        }
Пример #3
0
        static CodeFunction CodeFunction(this Project Project, MethodInfo Method)
        {
            var DeclaringType = Method.DeclaringType();

            return(Project.Classes()
                   .Where(x => x.FullName == DeclaringType)
                   .SelectMany(x => x.Functions())
                   .FirstOrDefault(x => x.EqualsTo(Method)));
        }
Пример #4
0
        void GotoDefinition()
        {
            try
            {
                var Sentence = TextView.Caret.Position.BufferPosition
                               .GetContainingLine().GetText().Trim();

                var ProjectItem = (Marshal.GetActiveObject("VisualStudio.DTE") as DTE).ActiveDocument.ProjectItem;

                var FeatureItem = ObjectFactory.FeatureItemFrom(ProjectItem);

                var FeatureContent = TextView.TextSnapshot.GetText();

                var project = Project.LoadFrom(FeatureItem);

                var Feature = ObjectFactory.NewFeatureParser.FeatureFrom(FeatureContent, FeatureItem);

                ObjectFactory.NewFeatureCompiler.Compile(Feature, FeatureItem);

                var Step = Feature.Steps.Find(x => x.Location.Content == Sentence);

                if (Step == null)
                {
                    return;
                }

                var CodeFunction = project.CodeFunction(Step);

                if (CodeFunction == null)
                {
                    MessageBox.Show("Step implementation not found ...");
                    return;
                }

                if (!CodeFunction.ProjectItem.IsOpen)
                {
                    CodeFunction.ProjectItem.Open();
                }

                var NavigatePoint = CodeFunction.GetStartPoint(vsCMPart.vsCMPartHeader);
                NavigatePoint.TryToShow();
                NavigatePoint.Parent.Selection.MoveToPoint(NavigatePoint);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error:" + e);
            }
        }
        // needs to b run from IDE
        public void should_load_Settings()
        {
            var Dte = Marshal.GetActiveObject("VisualStudio.DTE") as DTE;

            var DteProject = Dte.SelectedItems.Item(1).ProjectItem.ContainingProject;

            string fullPath = DteProject.Properties.Item("FullPath").Value.ToString();
            string outputPath = DteProject.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString();
            string outputDir = Path.Combine(fullPath, outputPath);
            string outputFileName = DteProject.Properties.Item("OutputFileName").Value.ToString();
            string assemblyPath = Path.Combine(outputDir, outputFileName);

            DteProject.Name.ShouldBe("Features");

            (assemblyPath).ShouldNotBeNull();

            var Project = new Project { DTEProject = DteProject };

            Project.Load();

            Settings.XUnit.Name.ShouldBe("MsTest");
        }
Пример #6
0
 public static CodeFunction CodeFunction(this Project Project, Step Step)
 {
     return(Step.IsImplemented ?
            Project.CodeFunction(Step.Implementation.Method) :
            Project.CodeFunctionForUnimplemented(Step));
 }
Пример #7
0
 public static IEnumerable <ProjectItem> Items(this Project Project)
 {
     return(Items(Project.DTEProject.ProjectItems));
 }
Пример #8
0
 static IEnumerable <CodeClass> Classes(this Project Project)
 {
     return(Project.Items()
            .Where(x => x.FileCodeModel != null)
            .SelectMany(projectItem => projectItem.FileCodeModel.CodeElements.Classes()));
 }