public void Add_should_obey_filtering()
        {
            var digraph = EmptyGraph();
            var graph = new AssemblyDependencyGraph(digraph, new AssemblyLoaderStub(), x => false);
            var assembly = new AssemblyStub("MyAssembly");
            graph.Add(assembly);

            digraph.Nodes.ShouldBeEmpty();
        }
        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" }));
        }
        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 }));
        }
        public void Should_support_filter_function()
        {
            var digraph = EmptyGraph();
            var graph = new AssemblyDependencyGraph(digraph, new AssemblyLoaderStub(), x => x.Name != "System");
            var assembly = GetAssemblyDependingOnSystem();

            graph.Add(assembly);

            Assert.That(digraph.Nodes.Map(x => x.Label).ToList(), Is.EquivalentTo(new[]{ assembly.Name.Name}));
        }