/
ReviewableTest.java
39 lines (34 loc) · 1.39 KB
/
ReviewableTest.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
package com.visionarysoftwaresolutions.reviewable;
import com.visionarysoftwaresolutions.reviewable.stubs.*;
import org.junit.Test;
import static org.junit.Assert.*;
public class ReviewableTest {
Reviewer nick = new User("nick");
Reviewable food = new Food("Phonecian Cafe Hummus");
@Test
public void testReview() {
//When I have the Reviewer review the Reviewable
Review result = nick.review(food,
"It is so creamy and delicious!");
//Then it is reviewed
assertEquals(result.getReviewer(), nick);
assertEquals(result.getReviewed(), food);
assertEquals(result.getDescription(), "It is so creamy and delicious!");
}
@Test
public void testDatedReview(){
//Given I'm reviewing something today
java.util.Date today = new java.util.Date();
//When I have a reviewer rate a reviewable
Review result = nick.review(food,
"It is so creamy and delicious!");
//And I want a Dated Review
DatedReview datedResult = new DatedReview(result);
//Then it is rated
assertEquals(datedResult.getReviewer(), nick);
assertEquals(datedResult.getReviewed(), food);
assertEquals(today.compareTo(datedResult.getDate()),-1);
assertEquals("It is so creamy and delicious! on " + today,
datedResult.getDescription());
}
}