project_result_test.rb
1.43 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
44
45
46
47
48
49
require "test_helper"
require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures"
class ProjectResultTest < ActiveSupport::TestCase
def setup
@hash = ProjectResultFixtures.qt_calculator_hash
@result = ProjectResultFixtures.qt_calculator
end
should 'create project result from hash' do
assert_equal @result, Kalibro::Entities::ProjectResult.from_hash(@hash)
end
should 'convert project result to hash' do
assert_equal @hash, @result.to_hash
end
should 'retrieve formatted load time' do
assert_equal '00:00:14', @result.formatted_load_time
end
should 'retrieve formatted analysis time' do
assert_equal '00:00:01', @result.formatted_analysis_time
end
should 'retrieve module node' do
node = @result.get_node("main")
assert_equal @hash[:source_tree][:child][2], node.to_hash
end
should 'retrive complex module' do
node = @result.get_node("org.Window")
assert_equal @hash[:source_tree][:child][0][:child].first, node.to_hash
end
should 'return source tree node when nil is given' do
assert_equal @hash[:source_tree], @result.node_of(nil).to_hash
end
should 'return source tree node when project name is given' do
assert_equal @hash[:source_tree], @result.node_of(@result.project.name).to_hash
end
should 'return correct node when module name is given' do
assert_equal @hash[:source_tree][:child][2], @result.node_of("main").to_hash
end
end