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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }