module_node_test.rb
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require "test_helper"
class ModuleNodeTest < ActiveSupport::TestCase
def self.qt_calculator_tree
node = Kalibro::Entities::ModuleNode.new
node.module = ModuleTest.qt_calculator
node.children = [new_node('Dialog', 'CLASS'), new_node('main', 'CLASS')]
node
end
def self.new_node(name, granularity)
the_module = Kalibro::Entities::Module.new
the_module.name = name
the_module.granularity = granularity
node = Kalibro::Entities::ModuleNode.new
node.module = the_module
node
end
def self.qt_calculator_tree_hash
{:module => ModuleTest.qt_calculator_hash,
:child => [
{:module => {:name => 'Dialog', :granularity => 'CLASS'}},
{:module => {:name => 'main', :granularity => 'CLASS'}}
]
}
end
def setup
@hash = self.class.qt_calculator_tree_hash
@node = self.class.qt_calculator_tree
end
should 'create module node from hash' do
assert_equal @node, Kalibro::Entities::ModuleNode.from_hash(@hash)
end
should 'convert children hash to array of ModuleNode' do
assert_equal @hash, @node.to_hash
end
end