public void Analyse_AssemblyWithMultipleReferences_HasOneDirectDependency()
 {
     // Arrange
     var name01 = "EjC.Tests.Assembly01";
     var name02 = "EjC.Tests.Assembly02";
     var name03 = "EjC.Tests.Assembly03";
     var refencedassembly01 = new AssemblyName(name01 + ", Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
     var refencedassembly02 = new AssemblyName(name02 + ", Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
     var refencedassembly03 = new AssemblyName(name03 + ", Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
     Assembly assembly = new StubAssembly()
     {
         GetReferencedAssemblies01 = () => new AssemblyName[] {
             refencedassembly01,
             refencedassembly02,
             refencedassembly03}
     };
     IAssemblyDependencies assemblyDepencies = new AssemblyDependencies();
     // Act
     assemblyDepencies.Analyse(assembly);
     var dependencies = assemblyDepencies.DirectDependencies.ToArray();
     // Assert
     Assert.AreEqual(3, dependencies.Count());
     Assert.IsTrue(dependencies.Contains(name01));
     Assert.IsTrue(dependencies.Contains(name02));
     Assert.IsTrue(dependencies.Contains(name03));
 }
Example #2
0
 static void Main(string[] args)
 {
     var assemblyName = args[0];
     var assemblyLoader = new AssemblyLoader();
     var assemblyDependencies = new AssemblyDependencies();
     IGraph<string> graph = new Graph<string>();
     AddAllDependencies(assemblyLoader, assemblyDependencies, graph, assemblyName);
     Console.WriteLine("digraph g {");
     foreach (var v in graph.Edges)
         Console.WriteLine("\"" + v.Parent + "\" -> \"" + v.Child + "\" ;");
     Console.WriteLine("}");
     Console.ReadLine();
 }
 public void Analyse_AssemblyWithNoReferencies_HasNoDirectDependencies()
 {
     // Arrange
     Assembly assembly = new StubAssembly()
     {
         GetReferencedAssemblies01 = () => new AssemblyName[] { }
     };
     IAssemblyDependencies assemblyDepencies = new AssemblyDependencies();
     // Act
     assemblyDepencies.Analyse(assembly);
     var dependencies = assemblyDepencies.DirectDependencies.ToArray();
     // Assert
     Assert.AreEqual(0, dependencies.Count());
 }
 public void Analyse_AssemblyWithOneReference_HasOneDirectDependency()
 {
     // Arrange
     var name = "EjC.Tests.Assembly01";
     var refencedassembly = new AssemblyName(name + ", Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
     Assembly assembly = new StubAssembly()
     {
         GetReferencedAssemblies01 = () => new AssemblyName[] { refencedassembly }
     };
     IAssemblyDependencies assemblyDepencies = new AssemblyDependencies();
     // Act
     assemblyDepencies.Analyse(assembly);
     var dependencies = assemblyDepencies.DirectDependencies.ToArray();
     // Assert
     Assert.AreEqual(1, dependencies.Count());
     Assert.AreEqual(name, dependencies[0]);
 }
Example #5
0
 private static void AddAllDependencies(AssemblyLoader assemblyLoader, AssemblyDependencies assemblyDependencies, IGraph<string> graph, string assemblyName)
 {
     if (graph.Edges.Select(v => v.Parent).Contains(assemblyName))
         return;
     assemblyLoader.RefeflectionOnly(assemblyName);
     if (assemblyLoader.AssemblyLoaded)
     {
         assemblyDependencies.Analyse(assemblyLoader.Assembly);
         graph.AddEdges(assemblyLoader.Name, assemblyDependencies.DirectDependencies);
         foreach (var dependency in assemblyDependencies.DirectDependencies)
         {
             AddAllDependencies(assemblyLoader, assemblyDependencies, graph, dependency);
         }
     }
     else
     {
         graph.AddEdges(assemblyName, new List<string>());
         //Console.WriteLine("    Assembly failed to load: {0}", assemblyName);
     }
 }
 public void Analyse_NullArgument_ThrowsException()
 {
     // Arrange
     IAssemblyDependencies assemblyDepencies = new AssemblyDependencies();
     // Act
     try
     {
         assemblyDepencies.Analyse(null);
         Assert.Fail("No exception thrown.");
     }
     catch (ArgumentNullException) { }
 }