public void NOCTester(string treeKey)
        {
            SyntaxTree tree = _treeDictionary[treeKey];

            int result = int.Parse(treeKey.Split("-")[0]);

            CSharpCompilation compilation = CSharpCompilation.Create("Trivial")
                                            .AddReferences(
                MetadataReference.CreateFromFile(
                    typeof(object).Assembly.Location))
                                            .AddSyntaxTrees(tree);

            SemanticModel model = compilation.GetSemanticModel(tree);

            IEnumerable <ClassDeclarationSyntax> classDeclarations = MetricRunner.GetClassesFromRoot(tree.GetRoot());

            var outgoingCouplings = CouplingBetweenObjects.CalculateCouplings(new List <SyntaxTree> {
                tree
            }, compilation);


            int noc = CouplingBetweenObjects.GetCount(classDeclarations.First(), model, outgoingCouplings);

            Assert.IsTrue(noc == result);
        }
Exemplo n.º 2
0
        public void RfcTester(string treeKey)
        {
            SyntaxTree tree = _treeDictionary[treeKey];

            int result = int.Parse(treeKey.Split('-')[0]);

            IEnumerable <ClassDeclarationSyntax> classDeclarations = MetricRunner.GetClassesFromRoot(tree.GetRoot());

            int rfc = ResponseForAClass.GetCount(classDeclarations.First());

            Assert.IsTrue(rfc == result);
        }
Exemplo n.º 3
0
        public void NocTester(string treeKey)
        {
            SyntaxTree tree = _treeDictionary[treeKey];

            int result = int.Parse(treeKey.Split("-")[0]);

            CSharpCompilation compilation = CSharpCompilation.Create("Trivial")
                                            .AddReferences(
                MetadataReference.CreateFromFile(
                    typeof(object).Assembly.Location))
                                            .AddSyntaxTrees(tree);

            SemanticModel model = compilation.GetSemanticModel(tree);

            IEnumerable <ClassDeclarationSyntax> classDeclarations = MetricRunner.GetClassesFromRoot(tree.GetRoot());

            Dictionary <INamedTypeSymbol, int> classExtensions = NumberOfChildren.GetClassExtensions(new List <SyntaxTree> {
                tree
            }, compilation);

            int noc = NumberOfChildren.GetCount(classDeclarations.First(), model, classExtensions);

            Assert.IsTrue(noc == result);
        }