-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobeHopperRatingTest.java
59 lines (53 loc) · 1.72 KB
/
GlobeHopperRatingTest.java
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
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
/*
* Unit Test for Rating Module
* On Globe Hopper Tour Video Interface
* since rating is a range
* and ratings for this application must be between
* 0 stars and 5 stars
* there are 3 possible input values for ratings:
* values less than 0
* values between 0 and 5
* values greater than 5
* only values between 0 and 5 are valid
*
*/
class GlobeHopperRatingTest {
// creates new test video to be rated
GHRating t1 = new GHRating();
@Test
void test4() {
// first test randomly adds 5 ratings between 0 and 5
for (int i = 0; i < 5; i++) {
int r = (int)(Math.random() * 5);
// since all values between 0 and 5 are accepted ...
assertEquals("Here is the test for rating authentication", true, t1.addRating(r));
// results in success
// and displays the correct information
}
}
@Test
void test5() {
// second test adds 5 ratings between -3 and 2
for (int i = 0; i < 5; i++) {
int r = (int)((Math.random() * 5) - 3);
// only values between 0 and 2 will be accepted
// detection of values less than 0 will terminate loop
assertEquals("Here is the test for rating authentication", true, t1.addRating(r));
// results in failure
}
}
@Test
void test6() {
// third test adds 5 ratings between 3 and 8
for (int i = 0; i < 5; i++) {
// only values between 3 and 5 will be accepted
int r = (int)((Math.random() * 5) + 3);
// detection of values greater than 5 will terminate loop
assertEquals("Here is the test for rating authentication", true, t1.addRating(r));
// results in failure
}
}
}