Sha256: 0c48dbec874cf19148f3a11ffebb85212d2252b3357d6c0fbab586e19b8cbc68

Contents?: true

Size: 1.36 KB

Versions: 73

Compression:

Stored size: 1.36 KB

Contents

require File.dirname(__FILE__) + '/helper'

class TestDependencyGraph < Test::Unit::TestCase
  def setup
    @dg = DependencyGraph.new
  end
  
  # new
  
  def test_new_should_accept_zero_arguments
    assert @dg.instance_of?(DependencyGraph)
  end
  
  # add
  
  def test_add_should_create_and_store_two_new_nodes
    @dg.add('foo', 'bar')
    assert_equal 2, @dg.nodes.size
    assert @dg.nodes['foo'].instance_of?(DependencyGraph::Node)
    assert @dg.nodes['bar'].instance_of?(DependencyGraph::Node)
  end
  
  def test_add_should_record_dependency
    @dg.add('foo', 'bar')
    assert_equal 1, @dg.nodes['foo'].dependencies.size
    assert_equal @dg.nodes['bar'], @dg.nodes['foo'].dependencies.first
  end
  
  def test_add_should_ignore_dups
    @dg.add('foo', 'bar')
    @dg.add('foo', 'bar')
    assert_equal 2, @dg.nodes.size    
    assert_equal 1, @dg.nodes['foo'].dependencies.size
  end
end


class TestDependencyGraphNode < Test::Unit::TestCase
  def setup
    @foo = DependencyGraph::Node.new('foo')
    @bar = DependencyGraph::Node.new('bar')
  end
  
  # new
  
  def test_new_should_accept_zero_arguments
    assert @foo.instance_of?(DependencyGraph::Node)
  end
  
  # add
  
  def test_add_should_store_node_as_dependency
    @foo.add(@bar)
    assert_equal 1, @foo.dependencies.size
  end
  
  # has_node?
  
  def test_has_node
    assert @foo.has_node?(@foo)
  end
end

Version data entries

73 entries across 73 versions & 22 rubygems

Version Path
dguettler-god-0.7.13.2 test/test_dependency_graph.rb
dguettler-god-0.7.13.3 test/test_dependency_graph.rb
dosire-god-0.7.10 test/test_dependency_graph.rb
dosire-god-0.7.12 test/test_dependency_graph.rb
dosire-god-0.7.9 test/test_dependency_graph.rb
dunedain289-god-0.7.12.1 test/test_dependency_graph.rb
dustin-god-0.7.7.1 test/test_dependency_graph.rb
eric-god-0.7.10 test/test_dependency_graph.rb
eric-god-0.7.11 test/test_dependency_graph.rb
eric-god-0.7.12 test/test_dependency_graph.rb
eric-god-0.7.14 test/test_dependency_graph.rb
eric-god-0.7.7 test/test_dependency_graph.rb
fotonauts-god-0.7.10 test/test_dependency_graph.rb
fotonauts-god-0.7.12 test/test_dependency_graph.rb
gohanlonllc-god-0.7.9 test/test_dependency_graph.rb
gordoncww-god-0.7.11.1 test/test_dependency_graph.rb
jreynolds-god-0.7.13 test/test_dependency_graph.rb
jwilkins-god-0.7.9 test/test_dependency_graph.rb
mathieuravaux-god-0.7.11 test/test_dependency_graph.rb
mojombo-god-0.7.10 test/test_dependency_graph.rb