20
20
import org.gmetrics.metric.abc.AbcVector
21
21
import org.gmetrics.metric.abc.AbcTestUtil
22
22
import org.gmetrics.metric.Metric
23
import org.gmetrics.metric.MetricLevel
25
26
* Tests for AbcMetricResult
27
28
* @author Chris Mair
28
* @version $Revision: 130 $ - $Date: 2010-07-21 22:46:24 -0400 (Wed, 21 Jul 2010) $
29
* @version $Revision: 163 $ - $Date: 2011-10-02 21:55:46 -0400 (Sun, 02 Oct 2011) $
30
31
class AbcMetricResultTest extends AbstractTestCase {
32
33
private static final DEFAULT_FUNCTION_NAMES = ['total', 'average', 'minimum', 'maximum']
33
34
private static final METRIC = new AbcMetric(functions:DEFAULT_FUNCTION_NAMES)
35
private static final ABC_VECTOR = new AbcVector(0, 0, 0)
35
37
void testPassingNullAbcVectorIntoConstructorThrowsException() {
36
shouldFailWithMessageContaining('abcVector') { new AbcMetricResult(METRIC, null) }
38
shouldFailWithMessageContaining('abcVector') { new AbcMetricResult(METRIC, MetricLevel.METHOD, null) }
41
void testPassingNullLevelIntoConstructorThrowsException() {
42
shouldFailWithMessageContaining('metricLevel') { new AbcMetricResult(METRIC, null, ABC_VECTOR) }
39
45
void testGetLineNumberIsSameValuePassedIntoConstructor() {
40
def abcVector = new AbcVector(0, 0, 0)
41
def result = new AbcMetricResult(METRIC, abcVector, 67)
46
def result = new AbcMetricResult(METRIC, MetricLevel.METHOD, ABC_VECTOR, 67)
42
47
assert result.getLineNumber() == 67
50
void testGetMetricLevelIsSameValuePassedIntoConstructor() {
51
def result = new AbcMetricResult(METRIC, MetricLevel.METHOD, ABC_VECTOR, 67)
52
assert result.getMetricLevel() == MetricLevel.METHOD
45
55
void testValuesForEmptyVectorSetIsZero() {
46
56
assert abcMetricResultAllFunctionValues(0, 0, 0) == 0