public override void VisitNamespaceDeclaration(NamespaceDeclarationSyntax node) { // Ensure that a CCNamespace is created for this namespace string namespaceName = GetNamespaceName(node); CCNamespace ns = codeModel.EnsureNamespace(namespaceName); // Collect distinct usings from inside the namespace declaration and from the surrounding compilation unit. CompilationUnitSyntax cunit = GetCompilationUnit(node); HashSet <string> usings = new HashSet <string>(); foreach (var u in node.Usings) { usings.Add(u.Name.ToString()); } foreach (var u in cunit.Usings) { usings.Add(u.Name.ToString()); } // Increment outgoing dependencies of the current namespace declaration ns.OutgoingDependencies += usings.Count; // Increment incoming depedencies for each referenced namespace. foreach (var uname in usings) { CCNamespace d = codeModel.EnsureNamespace(uname); d.IncomingDependencies++; } base.VisitNamespaceDeclaration(node); }
public void PetshopOrderNumberOfProperties() { CCNamespace ordering = codeModel.GetNamespaceByName("Petshop.Ordering"); CCClass order = ordering.GetClassByName("Order"); Assert.AreEqual(1, order.NumberOfProperties); }
public void PetshopOrderManagementNumberOfFields() { CCNamespace ordering = codeModel.GetNamespaceByName("Petshop.Ordering"); CCClass orderManagement = ordering.GetClassByName("OrderManagement"); Assert.AreEqual(1, orderManagement.NumberOfFields); }
public void PetshopNamespaces() { Assert.AreEqual(7, codeModel.Namespaces.Count); CCNamespace rootByName = codeModel.GetNamespaceByName("Petshop"); Assert.IsNotNull(rootByName); Assert.AreEqual(4, rootByName.Namespaces.Count); CCNamespace rootByParentNull = codeModel.GetRootNamespaces()[0]; Assert.AreEqual("Petshop", rootByParentNull.Name); Assert.AreEqual(4, rootByParentNull.Namespaces.Count); Assert.AreEqual(rootByName, rootByParentNull); CCNamespace messaging = codeModel.GetNamespaceByName("Petshop.Messaging"); Assert.IsNotNull(messaging); Assert.AreEqual(1, messaging.Namespaces.Count); CCNamespace email = codeModel.GetNamespaceByName("Petshop.Messaging.Email"); CCNamespace rootFromEmail = email.Parent.Parent; Assert.IsNotNull(rootFromEmail); Assert.AreEqual(rootByName, rootFromEmail); }
public void PetshopOrderManagementNumberOfIndependentPaths() { CCNamespace ordering = codeModel.GetNamespaceByName("Petshop.Ordering"); CCClass orderManagement = ordering.GetClassByName("OrderManagement"); // two methods, if statements, loops, catch clauses, switch cases. Assert.AreEqual(13, orderManagement.NumberOfIndependentPaths); }
public void PetshopOrderManagementNumberOfStatements() { CCNamespace ordering = codeModel.GetNamespaceByName("Petshop.Ordering"); CCClass orderManagement = ordering.GetClassByName("OrderManagement"); // Only statements, no blocks (but conditions inside a loop of if statement) Assert.AreEqual(19, orderManagement.NumberOfStatements); }
private static GoCityNode CreateGoCityNode(CCNamespace ns) { var nsNode = new GoCityNode { Name = ns.Name, NType = GoCityNodeType.PACKAGE, }; foreach (var c in ns.Classes) { nsNode.Children.Add(CreateGoCityNode(c)); } foreach (var n in ns.Namespaces) { nsNode.Children.Add(CreateGoCityNode(n)); } return(nsNode); }
public void PetshopOrderingIncomingDependencies() { CCNamespace ordering = codeModel.GetNamespaceByName("Petshop.Ordering"); Assert.AreEqual(1, ordering.IncomingDependencies); }
public void PetshopEmailClasses() { CCNamespace email = codeModel.GetNamespaceByName("Petshop.Messaging.Email"); Assert.AreEqual(1, email.Classes.Count); }