Exemplo n.º 1
0
        public void Should_follow_dependency_chain()
        {
            var digraph = EmptyGraph();
            var loader = new AssemblyLoaderStub();
            var graph = new AssemblyDependencyGraph(digraph, loader);
            var root = new AssemblyStub("RootAssembly");
            var systemXml = new AssemblyStub("System.Xml");
            var system = new AssemblyName("System");
            var loaded = new List<AssemblyName>();

            loader.Loading += loaded.Add;
            loader.Add(systemXml);

            root.GetReferencedAssembliesHandler = () => new []{ systemXml.Name };
            systemXml.GetReferencedAssembliesHandler = () => new []{ system };

            graph.Add(root);

            Assert.That(loaded.Map(x => x.Name).ToList(), Is.EquivalentTo(new[] { system.Name, systemXml.Name.Name }));
        }
Exemplo n.º 2
0
        public void Should_handle_circular_dependencies()
        {
            var digraph = EmptyGraph();
            var loader = new AssemblyLoaderStub();
            var graph = new AssemblyDependencyGraph(digraph, loader);
            var system = new AssemblyStub("System");
            var systemXml = new AssemblyStub("System.Xml");

            system.GetReferencedAssembliesHandler = () => new[] { systemXml.Name };
            systemXml.GetReferencedAssembliesHandler = () => new[] { system.Name };

            loader.Add(system);
            loader.Add(systemXml);

            graph.Add(system);

            Assert.That(digraph.Edges.Map(x => x.ToString()).ToList(), Is.EquivalentTo(new[] { "0->1", "1->0" }));
        }