Example #1
0
        private static async Task <List <UnitTestClassItem> > GetUnitTestItems(string solutionFullPath)
        {
            var unitTestItems = new List <UnitTestClassItem>();

            foreach (var project in await SolutionHelper.GetProjectsAsync(solutionFullPath).ConfigureAwait(false))
            {
                foreach (var csFile in project.GetCSharpFiles())
                {
                    var root = await csFile.GetSyntaxRootAsync().ConfigureAwait(false);

                    if (root.ToFullString().Contains(".Fakes"))
                    {
                        var semanticModel = await csFile.GetSemanticModelAsync().ConfigureAwait(false);

                        foreach (var unitTestClass in root.DescendantNodes()
                                 .OfType <ClassDeclarationSyntax>())
                        {
                            unitTestItems.Add(new UnitTestClassItem()
                            {
                                Workspace     = project.Solution.Workspace,
                                File          = csFile,
                                Root          = root,
                                SemanticModel = semanticModel,
                                UnitTestClass = unitTestClass
                            });
                        }
                    }
                }
            }

            return(unitTestItems);
        }