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
god-0.9.0 test/test_dependency_graph.rb
olgen-god-0.9.2 test/test_dependency_graph.rb
olgen-god-0.9.1 test/test_dependency_graph.rb
olgen-god-0.9.0 test/test_dependency_graph.rb
god-0.8.0 test/test_dependency_graph.rb
olgen-god-0.8.2 test/test_dependency_graph.rb
olgen-god-0.8.1 test/test_dependency_graph.rb
olgen-god-0.8.0 test/test_dependency_graph.rb
god-0.7.22 test/test_dependency_graph.rb
god-0.7.21 test/test_dependency_graph.rb
god-0.7.20 test/test_dependency_graph.rb
god-0.7.19 test/test_dependency_graph.rb
god-0.7.18 test/test_dependency_graph.rb
god-0.7.17 test/test_dependency_graph.rb
god-0.7.16 test/test_dependency_graph.rb
god-0.7.15 test/test_dependency_graph.rb
god-0.7.14 test/test_dependency_graph.rb
god-0.4.0 test/test_dependency_graph.rb
god-0.7.0 test/test_dependency_graph.rb
god-0.7.11 test/test_dependency_graph.rb