[r2493]: osmf / trunk / framework / OSMFTest / src / org / osmf / net / rules / TestRecommendation.as Maximize Restore History

Download this file

TestRecommendation.as    128 lines (112 with data), 4.1 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
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*****************************************************
*
* Copyright 2011 Adobe Systems Incorporated. All Rights Reserved.
*
*****************************************************
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
*
* The Initial Developer of the Original Code is Adobe Systems Incorporated.
* Portions created by Adobe Systems Incorporated are Copyright (C) 2011 Adobe Systems
* Incorporated. All Rights Reserved.
*
*****************************************************/
package org.osmf.net.rules
{
import flexunit.framework.Assert;
import org.flexunit.asserts.assertEquals;
public class TestRecommendation
{
[Before]
public function setUp():void
{
}
[After]
public function tearDown():void
{
}
[BeforeClass]
public static function setUpBeforeClass():void
{
}
[AfterClass]
public static function tearDownAfterClass():void
{
}
[Test]
public function testGet():void
{
recommendation = new Recommendation(RULE_TYPE, 467.8, 0.88);
assertEquals(RULE_TYPE, recommendation.ruleType);
assertEquals(467.8, recommendation.bitrate);
assertEquals(0.88, recommendation.confidence);
}
[Test]
public function testRecommendationInitValidConfidence():void
{
recommendation = new Recommendation(RULE_TYPE, 467.8, 0);
assertEquals(RULE_TYPE, recommendation.ruleType);
assertEquals(467.8, recommendation.bitrate);
assertEquals(0, recommendation.confidence);
recommendation = new Recommendation(RULE_TYPE, 467.8, 1);
assertEquals(467.8, recommendation.bitrate);
assertEquals(1, recommendation.confidence);
recommendation = new Recommendation(RULE_TYPE, 467.8, 0.2);
assertEquals(467.8, recommendation.bitrate);
assertEquals(0.2, recommendation.confidence);
}
[Test]
public function testRecommendationInitValidBitrate():void
{
recommendation = new Recommendation(RULE_TYPE, 0, 0.5);
assertEquals(0, recommendation.bitrate);
assertEquals(0.5, recommendation.confidence);
recommendation = new Recommendation(RULE_TYPE, 467, 0.5);
assertEquals(467, recommendation.bitrate);
assertEquals(0.5, recommendation.confidence);
recommendation = new Recommendation(RULE_TYPE, 467.8, 0.5);
assertEquals(467.8, recommendation.bitrate);
assertEquals(0.5, recommendation.confidence);
}
[Test(expects="ArgumentError")]
public function testRecommendationInvalidConfidenceNaN():void
{
recommendation = new Recommendation(RULE_TYPE, 400, Number.NaN);
}
[Test(expects="ArgumentError")]
public function testRecommendationInvalidConfidenceNegative():void
{
recommendation = new Recommendation(RULE_TYPE, 400, -0.1);
}
[Test(expects="ArgumentError")]
public function testRecommendationInvalidConfidenceOverOne():void
{
recommendation = new Recommendation(RULE_TYPE, 400, 1.1);
}
[Test(expects="ArgumentError")]
public function testRecommendationInvalidBitrateNegative():void
{
recommendation = new Recommendation(RULE_TYPE, -0.1, 0.5);
}
[Test(expects="ArgumentError")]
public function testRecommendationInvalidBitrateNaN():void
{
recommendation = new Recommendation(RULE_TYPE, Number.NaN, 0.5);
}
[Test(expects="ArgumentError")]
public function testRecommendationInvalidRuleType():void
{
recommendation = new Recommendation(null, 400, 0.5);
}
private var recommendation:Recommendation;
private static const RULE_TYPE:String = "sample_rule_type";
}
}