metric_result_test.rb
1.49 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
50
51
52
53
54
55
require "test_helper"
class MetricResultTest < ActiveSupport::TestCase
def self.amloc_result
result = Kalibro::Entities::MetricResult.new
result.metric = NativeMetricTest.amloc
result.value = 0.0
result.descendent_results = [40.0, 42.0]
result.range = RangeTest.amloc_excellent
result
end
def self.sc_result
result = Kalibro::Entities::MetricResult.new
result.metric = CompoundMetricTest.sc
result.value = 1.0
result.descendent_results = [2.0, 42.0]
result
end
def self.amloc_result_hash
{:metric => NativeMetricTest.amloc_hash,
:value => 0.0, :descendent_result => [40.0, 42.0],
:range => RangeTest.amloc_excellent_hash}
end
def self.sc_result_hash
{:metric => CompoundMetricTest.sc_hash,
:value => 1.0, :descendent_result => [2.0, 42.0]}
end
def setup
@hash = self.class.amloc_result_hash
@result = self.class.amloc_result
end
should 'create metric result from hash' do
assert_equal @result, Kalibro::Entities::MetricResult.from_hash(@hash)
end
should 'convert metric result to hash' do
assert_equal @hash, @result.to_hash
end
should 'create appropriate metric type' do
assert self.class.amloc_result.metric.instance_of?(Kalibro::Entities::NativeMetric)
assert self.class.sc_result.metric.instance_of?(Kalibro::Entities::CompoundMetric)
end
should 'convert single descendent result to array' do
@result.descendent_result = 1
assert_equal [1], @result.descendent_results
end
end