public void SwitchWithIf_Scores_2() { var method = root.DescendantNodesAndSelf().OfType <MethodDeclarationSyntax>().First(method => method.Identifier.ValueText == "SwitchWithIf"); var score = CognitiveComplexityAnalyzer.AnalyzeMethod(method); Assert.Equal(2, score); }
public void NestedIfAndOr_Scores5() { var method = root.DescendantNodesAndSelf().OfType <MethodDeclarationSyntax>().First(method => method.Identifier.ValueText == "NestedIfAndOr"); var score = CognitiveComplexityAnalyzer.AnalyzeMethod(method); Assert.Equal(5, score); }
public void ForLoopWithMethodCallDeclaration_Scores2() { var method = root.DescendantNodesAndSelf().OfType <MethodDeclarationSyntax>().First(method => method.Identifier.ValueText == "ForLoopWithMethodCallForDeclaration"); var score = CognitiveComplexityAnalyzer.AnalyzeMethod(method); Assert.Equal(2, score); }
public void DoWhileWithConditionAndStatementScores5() { var method = root.DescendantNodesAndSelf().OfType <MethodDeclarationSyntax>().First(method => method.Identifier.ValueText == "DoWhileWithConditionAndStatements"); var score = CognitiveComplexityAnalyzer.AnalyzeMethod(method); Assert.Equal(5, score); }
public void DoWhileScores1() { var method = root.DescendantNodesAndSelf().OfType <MethodDeclarationSyntax>().First(method => method.Identifier.ValueText == "SimpleDoWhile"); var score = CognitiveComplexityAnalyzer.AnalyzeMethod(method); Assert.Equal(1, score); }
public void ForEachLoopWithIfInLoop_Scores3() { var method = root.DescendantNodesAndSelf().OfType <MethodDeclarationSyntax>().First(method => method.Identifier.ValueText == "SimpleForEachWithIfInLoop"); var score = CognitiveComplexityAnalyzer.AnalyzeMethod(method); Assert.Equal(3, score); }