Exemplo n.º 1
0
 public void NamespaceUsageTest()
 {
     var type = GetType();
     var namespaceDefinition = new NamespaceDefinition();
     namespaceDefinition.Name = "MyName";
     Assert.AreEqual("MyName", namespaceDefinition.Name);
     namespaceDefinition.AddType(type);
     Assert.AreEqual(1, namespaceDefinition.Types.Count);
     Assert.AreEqual(1, namespaceDefinition.GetTypes().Count());
     Assert.IsNotNull(namespaceDefinition.GetTypes().First());
     Assert.IsNotNull(namespaceDefinition.Types.First());
     var textSerialization = namespaceDefinition.ToString();
     Assert.IsNotNull(textSerialization);
     Assert.IsTrue(textSerialization.Contains(type.FullName));
 }
Exemplo n.º 2
0
 public void ApiTest()
 {
     var myNamespace = new NamespaceDefinition();
     myNamespace.AddType(typeof (MyClass));
     var api = new AssemblyApi(new List<NamespaceDefinition> {myNamespace});
     var namespaces = api.GetNamespaces().ToList();
     Assert.AreEqual(1, namespaces.Count);
     foreach (var nspace in namespaces)
     {
         var classes = nspace.Types.ToList();
         Assert.AreEqual(1, classes.Count);
         foreach (var c in classes)
         {
             var members = c.GetPublicMembersSignatures().ToList();
             Assert.AreEqual(5, members.Count);
         }
     }
 }
Exemplo n.º 3
0
 public AssemblyApi ExtractApi(string assemblyPath)
 {
     var assembly = Loader.LoadFrom(assemblyPath);
     var types = assembly.GetTypes();
     var namespaces = new Dictionary<string, NamespaceDefinition>();
     foreach (var type in types)
     {
         NamespaceDefinition nspace;
         var space = type.Namespace;
         if (string.IsNullOrEmpty(space))
         {
             space = "NULL";
         }
         if (!namespaces.TryGetValue(space, out nspace))
         {
             nspace = new NamespaceDefinition(space);
             namespaces[space] = nspace;
         }
         nspace.AddType(type);
     }
     return new AssemblyApi(namespaces.Values);
 }