Ejemplo n.º 1
0
        private void TestName_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            string unitTestMethodName = ((TextBox)sender).Text;

            _queries = TestifyQueries.Instance;
            int       line   = 0;
            const int column = 1;

            string name = string.Empty;
            Window openDocumentWindow;

            var    unitTest = _queries.GetUnitTestByName(unitTestMethodName).FirstOrDefault();
            string filePath = unitTest.FilePath;

            line = unitTest.LineNumber;
            var dte = Package.GetGlobalService(typeof(DTE)) as DTE2;

            if (!string.IsNullOrEmpty(filePath) && filePath != string.Empty && !dte.ItemOperations.IsFileOpen(filePath))
            {
                openDocumentWindow = dte.ItemOperations.OpenFile(filePath);
                if (openDocumentWindow != null)
                {
                    ActivateWindowAtUnitTest(line, column, openDocumentWindow);
                }
                else
                {
                    for (int i = 1; i == dte.Documents.Count; i++)
                    {
                        if (dte.Documents.Item(i).Name == name)
                        {
                            openDocumentWindow = dte.Documents.Item(i).ProjectItem.Document.ActiveWindow;
                            ActivateWindowAtUnitTest(line, column, openDocumentWindow);
                        }
                    }
                }
            }

            else
            {
                for (int i = 1; i <= dte.Windows.Count; i++)
                {
                    Window window = dte.Windows.Item(i);
                    if (window.Document != null && window
                        .Document.FullName.Equals(filePath, StringComparison.OrdinalIgnoreCase))
                    {
                        //openDocumentWindow = window;
                        ActivateWindowAtUnitTest(line, column, window);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void VerifyProjects(EnvDTE.Project project)
        {
            var projects     = new List <Poco.Project>();
            var outputPath   = GetProjectOutputBuildFolder(project);
            var assemblyName = GetProjectPropertyByName(project.Properties, "AssemblyName");

            projects.Add(new Poco.Project
            {
                Name         = project.Name,
                AssemblyName = assemblyName,
                UniqueName   = project.UniqueName,
                Path         = outputPath
            });
            _queries = TestifyQueries.Instance;
            TestifyQueries.SolutionName = _dte.Solution.FullName;

            _queries.MaintainProjects(projects);
        }
Ejemplo n.º 3
0
        //private void ProcessProjectLevelQueue(object source, ElapsedEventArgs e)
        //{
        //    if (_service != null)
        //    {
        //        _service.ProcessProjectTestQueue(++_testRunId);
        //    }
        //}

        private async void VerifyProjects(IVsSolution solution, string projectName)
        {
            //List<EnvDTE.Project> vsProjects = new List<EnvDTE.Project>();
            if (_queries == null)
            {
                object solutionName;
                solution.GetProperty((int)__VSPROPID.VSPROPID_SolutionFileName, out solutionName);
                _solutionName = solutionName.ToString();
                _queries      = TestifyQueries.Instance;
                TestifyQueries.SolutionName = _solutionName;
            }


            var pocoProjects = new List <Poco.Project>();

            foreach (EnvDTE.Project project in _dte.Solution.Projects)
            {
                if (projectName == string.Empty || project.UniqueName.Equals(projectName))
                {
                    _documentEvents = _dte.Events.DocumentEvents;
                    _documentEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(this.OnDocumentSaved);
                    //_documentEvents.DocumentOpened += new _dispDocumentEvents_DocumentOpeningEventHandler(this.DocumentOpened);
                    var outputPath   = GetProjectOutputBuildFolder(project);
                    var assemblyName = GetProjectPropertyByName(project.Properties, "AssemblyName");

                    _log.DebugFormat("Verify project name: {0}", project.Name);
                    _log.DebugFormat("  outputPath: {0}", outputPath);
                    _log.DebugFormat("  Assembly name: {0}", assemblyName);

                    pocoProjects.Add(new Poco.Project
                    {
                        Name         = project.Name,
                        AssemblyName = assemblyName,
                        UniqueName   = project.UniqueName,
                        Path         = outputPath
                    });
                }
            }



            _queries.MaintainProjects(pocoProjects);
        }
Ejemplo n.º 4
0
        //private readonly ILog Log = LogManager.GetLogger(typeof(SummaryViewControl));

        public SummaryViewControl(TestifyCoverageWindow parent)
        {
            InitializeComponent();
            _parent  = parent;
            _queries = TestifyQueries.Instance;



            if (TestifyQueries.SolutionName != null)
            {
                //Todo make this async
                Task <CoverageViewModel> coverageViewModel = GetSummariesAsync();
                coverageViewModel.Wait();
                base.DataContext = coverageViewModel.Result;

                treeGrid.DataContext = coverageViewModel.Result;
            }
            else
            {
                base.DataContext = new SummaryViewModel();
            }
        }
Ejemplo n.º 5
0
        public int OnAfterOpenSolution(object pUnkReserved, int fNewSolution)
        {
            // if the user closes a solution and opens another, we need to rebuild the ConnectionString
            if (_queries != null)
            {
                _queries = null;
            }

            IVsSolution solution = SetSolutionValues();

            _dte = (DTE)GetService(typeof(DTE));

            _log.DebugFormat("Solution Opened: {0}", _solutionName);
            _service = new UnitTestService(_dte, _solutionDirectory, _solutionName);
            var appDataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            var databasePath = GetDatabasePath(appDataDirectory);

            CheckForDatabase(databasePath);

            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            var solutionTestsMenuCommand = mcs.FindCommand(new CommandID(Testify.GuidList.GuidTestifyCmdSet, (int)PkgCmdIDList.cmdidSolutionTests));

            solutionTestsMenuCommand.Enabled = true;

            var projectTestsMenuCommand = mcs.FindCommand(new CommandID(Testify.GuidList.GuidTestifyCmdSet, (int)PkgCmdIDList.cmdidSolutionTests));

            projectTestsMenuCommand.Enabled = true;

            // Setup Project Build Event Handler

            var projectEvents = ((Events2)_dte.Events).BuildEvents;

            projectEvents.OnBuildProjConfigDone += ProjectBuildEventHandler;

            VerifyProjects(solution, string.Empty);
            _queries.SetAllQueuedTestsToNotRunning();
            return(VSConstants.S_OK);
        }
Ejemplo n.º 6
0
        public UnitTestService(DTE dte, string solutionDirectory, string solutionName)
        {
            Log.DebugFormat("Inside 3 argument Constructor");
            _dte     = dte;
            _queries = TestifyQueries.Instance;

            TestifyQueries.SolutionName = solutionName;

            _solutionName = solutionName;

            _solutionDirectory = solutionDirectory;

            _openCoverCommandLine = Path.GetDirectoryName(typeof(UnitTestService).Assembly.Location) + @"\OpenCover\OpenCover.console.exe";

            _nunitPath = Path.GetDirectoryName(typeof(UnitTestService).Assembly.Location) + @"\NUnit.Runners.2.6.2\nunit-console.exe";

            Log.DebugFormat("Load file paths for Release Mode");
            Log.DebugFormat("Release Path for OpenCover: {0}", _openCoverCommandLine);
            Log.DebugFormat("Release Path for NUnit: {0}", _nunitPath);
            Log.DebugFormat("Nunit Path: {0}", _nunitPath);

            _outputFolder = GetOutputFolder();
        }
Ejemplo n.º 7
0
 public ClassViewModel(Poco.CodeClass codeClass, ModuleViewModel parentModule)
     : base(parentModule, true)
 {
     _class   = codeClass;
     _queries = TestifyQueries.Instance;
 }
Ejemplo n.º 8
0
 public ModuleViewModel(Poco.CodeModule module)
     : base(null, true)
 {
     _module  = module;
     _queries = TestifyQueries.Instance;
 }
Ejemplo n.º 9
0
        void ItemDoubleClicked(object sender, RoutedEventArgs e)
        {
            _queries = TestifyQueries.Instance;
            string filePath = string.Empty;
            int    line     = 0;
            int    column   = 0;
            string type     = ((HeaderedItemsControl)(e.Source)).Header.ToString();
            string name     = string.Empty;

            EnvDTE.Window openDocumentWindow;
            var           clickedMethodName = string.Empty;

            var dte = TestifyPackage.GetGlobalService(typeof(DTE)) as DTE2;

            //IList<CodeElement> classes;
            //IList<CodeElement> methods;
            if (dte.ActiveDocument != null)
            {
                //CodeModelService.GetCodeBlocks(dte.ActiveDocument.ProjectItem.FileCodeModel, out classes, out methods);

                if (type == "Leem.Testify.SummaryView.ViewModel.MethodViewModel")
                {
                    clickedMethodName = ((MethodViewModel)(((System.Windows.Controls.HeaderedItemsControl)(e.Source)).Header)).FullName;

                    // var method = _queries.GetMethod(clickedMethodName);
                    filePath = ((MethodViewModel)(((System.Windows.Controls.HeaderedItemsControl)(e.Source)).Header)).FileName;
                    line     = ((MethodViewModel)(((System.Windows.Controls.HeaderedItemsControl)(e.Source)).Header)).Line;
                    column   = ((MethodViewModel)(((System.Windows.Controls.HeaderedItemsControl)(e.Source)).Header)).Column;
                }
            }


            if (!string.IsNullOrEmpty(filePath) && filePath != string.Empty && !dte.ItemOperations.IsFileOpen(filePath))
            {
                openDocumentWindow = dte.ItemOperations.OpenFile(filePath);
                if (openDocumentWindow != null)
                {
                    openDocumentWindow.Activate();
                }
                else
                {
                    for (var i = 1; i == dte.Documents.Count; i++)
                    {
                        if (dte.Documents.Item(i).Name == name)
                        {
                            openDocumentWindow = dte.Documents.Item(i).ProjectItem.Document.ActiveWindow;
                        }
                    }
                }
            }

            else
            {
                for (var i = 1; i <= dte.Windows.Count; i++)
                {
                    var window = dte.Windows.Item(i);
                    if (window.Document != null && window.Document.FullName.Equals(filePath, StringComparison.OrdinalIgnoreCase))
                    {
                        openDocumentWindow = window;
                        openDocumentWindow.Activate();
                        var selection = window.Document.DTE.ActiveDocument.Selection as TextSelection;
                        selection.StartOfDocument();
                        selection.MoveToLineAndOffset(line, column, true);

                        selection.SelectLine();

                        continue;
                    }
                }
            }
        }