public void Should_create_distinct_nodes_for_types_with_same_name()
        {
            var digraph = EmptyGraph();
            var graph = new TypeDependencyGraph(digraph);
            graph.Add(new TypeStub("NamespaceOne", "Foo"));
            graph.Add(new TypeStub("NamespaceTwo", "Foo"));

            digraph.Nodes.Count().ShouldEqual(2);
        }
        public void Should_ignore_generated_types()
        {
            var digraph = EmptyGraph();
            var graph = new TypeDependencyGraph(digraph);
            graph.Add(new TypeStub("Generated"){ GetIsGeneratedHandler = () => true });

            digraph.Nodes.ShouldBeEmpty();
        }
        public void Add_should_create_node_for_type()
        {
            var digraph = EmptyGraph();
            var graph = new TypeDependencyGraph(digraph);
            graph.Add(new TypeStub("MyType"));

            Assert.That(digraph.Nodes.Map(x => x.Label).ToList(), Is.EquivalentTo(new[]{ "MyType" }));
        }
        public void Add_should_create_nodes_for_dependencies()
        {
            var digraph = EmptyGraph();
            var graph = new TypeDependencyGraph(digraph);
            graph.Add(new TypeStub("MyType"){ GetDependsOnHandler = () => new[]{new TypeStub("DateTime") } });

            Assert.That(digraph.Nodes.Map(x => x.Label).ToList(), Is.EquivalentTo(new[]{ "MyType", "DateTime" }));
        }
        public void Should_ignore_generated_dependent_on_types()
        {
            var digraph = EmptyGraph();
            var graph = new TypeDependencyGraph(digraph);
            graph.Add(new TypeStub("MyType"){ GetDependsOnHandler = () => new[]
            {
                new TypeStub("Generated"){ GetIsGeneratedHandler = () => true }
            }});

            Assert.That(digraph.Nodes.Map(x => x.Label).ToList(), Is.EquivalentTo(new[]{ "MyType" }));
        }
        public void Add_should_create_edges_between_dependencies()
        {
            var digraph = EmptyGraph();
            var graph = new TypeDependencyGraph(digraph);
            graph.Add(new TypeStub("MyType"){ GetDependsOnHandler = () => new[]
            {
                new TypeStub("DateTime"), new TypeStub("Object")
            } });

            Assert.That(digraph.Edges.Map(x => x.ToString()).ToList(), Is.EquivalentTo(new[] { "0->1", "0->2" }));
        }
 public void Should_raise_NodeCreated_when_adding_node()
 {
     var digraph = EmptyGraph();
     var graph = new TypeDependencyGraph(digraph);
     var nodeCreatedRaised = false;
     graph.NodeCreated += (sender, e) =>
     {
         Assert.AreSame(sender, graph);
         e.Item.Equals(typeof(EmptyType)).ShouldBe(true);
         nodeCreatedRaised = true;
     };
     graph.Add(TypeLoader.FromNative(typeof(EmptyType)));
     nodeCreatedRaised.ShouldBe(true);
 }
 public void Wont_add_duplicate_edge_for_type_and_type_array()
 {
     var digraph = EmptyGraph();
     var graph = new TypeDependencyGraph(digraph);
     graph.Add(TypeLoader.FromNative(typeof(TypeWithArray)));
     Assert.That(digraph.Edges.Map(x => x.ToString()).ToList(), Is.EquivalentTo(new[] { "0->1" }));
 }
 public void Should_use_element_type_for_arrays()
 {
     var digraph = EmptyGraph();
     var graph = new TypeDependencyGraph(digraph);
     graph.Add(TypeLoader.FromNative(typeof(MyType)));
     Assert.That(digraph.Nodes.Map(x => x.Label).ToList(), Is.EquivalentTo(new[]{ "MyType", "DateTime" }));
 }
        public void Should_support_filtering()
        {
            var digraph = EmptyGraph();
            var graph = new TypeDependencyGraph(digraph, Filter.From<IType>(x => false));
            graph.Add(new TypeStub("MyType"));

            digraph.Nodes.ShouldBeEmpty();
        }