Esempio n. 1
0
        private void actRunTests_Execute(ExecuteEventArgs ea)
        {
            ResetTestResults();

            string className = CodeRush.Source.ActiveClass.FullName;

            if (CodeRush.Source.ActiveMethod != null)
            {// Handle trigger in method
                string    methodName    = CodeRush.Source.ActiveMethod.Name;
                Attribute testAttribute = DxCoreUtil.GetFirstTestAttribute(CodeRush.Source.ActiveMethod);
                if (testAttribute != null)
                {
                    StandardRunTestBehavior(RunnerFactory.CreateRunnerFromTestAttribute(testAttribute.GetDeclaration().FullName),
                                            (run, assemblyPath, assemblyName) => run.RunTests(assemblyPath, assemblyName, className, methodName));
                }
            }
            else
            {// Handle trigger in class
                string fixtureAttribute = CodeRush.Source.ActiveClass.AttributeCount > 0 ? ((Attribute)CodeRush.Source.ActiveClass.Attributes[0]).GetDeclaration().FullName : string.Empty;
                StandardRunTestBehavior(RunnerFactory.CreateRunnerFromFixtureAttribute(fixtureAttribute),
                                        (run, assemblyPath, assemblyName) => run.RunTests(assemblyPath, assemblyName, className));
            }
        }