|
6 | 6 | import org.junit.experimental.theories.PotentialAssignment.CouldNotGenerateValueException;
|
7 | 7 |
|
8 | 8 | public class PotentialAssignmentTest {
|
9 |
| - |
10 |
| - @Test |
11 |
| - public void shouldUseQuotedValueInDescription() throws CouldNotGenerateValueException { |
12 |
| - String name = "stringDatapoint"; |
13 |
| - Object value = new Object() { |
14 |
| - @Override |
15 |
| - public String toString() { |
16 |
| - return "string value"; |
17 |
| - } |
18 |
| - }; |
19 |
| - |
20 |
| - PotentialAssignment assignment = PotentialAssignment.forValue(name, value); |
21 |
| - |
22 |
| - assertEquals("\"string value\" <from stringDatapoint>", assignment.getDescription()); |
23 |
| - } |
24 |
| - |
25 |
| - @Test |
26 |
| - public void shouldNotUseQuotesForNullValueDescriptions() throws CouldNotGenerateValueException { |
27 |
| - String name = "nullDatapoint"; |
28 |
| - Object value = null; |
29 |
| - |
30 |
| - PotentialAssignment assignment = PotentialAssignment.forValue(name, value); |
31 |
| - |
32 |
| - assertEquals("null <from nullDatapoint>", assignment.getDescription()); |
33 |
| - } |
34 |
| - |
35 |
| - @Test |
36 |
| - public void shouldIncludeFailureInDescriptionIfToStringFails() throws CouldNotGenerateValueException { |
37 |
| - String name = "explodingValue"; |
38 |
| - Object value = new Object() { |
39 |
| - @Override |
40 |
| - public String toString() { |
41 |
| - throw new RuntimeException("Oh no!"); |
42 |
| - } |
43 |
| - }; |
44 |
| - |
45 |
| - PotentialAssignment assignment = PotentialAssignment.forValue(name, value); |
46 |
| - |
47 |
| - assertEquals("[toString() threw RuntimeException: Oh no!] <from explodingValue>", assignment.getDescription()); |
48 |
| - } |
49 |
| - |
50 |
| - @Test |
51 |
| - public void shouldReturnGivenValue() throws CouldNotGenerateValueException { |
52 |
| - Object value = new Object(); |
53 |
| - PotentialAssignment assignment = PotentialAssignment.forValue("name", value); |
54 |
| - assertEquals(value, assignment.getValue()); |
55 |
| - } |
| 9 | + |
| 10 | + @Test |
| 11 | + public void shouldUseQuotedValueInDescription() throws CouldNotGenerateValueException { |
| 12 | + String name = "stringDatapoint"; |
| 13 | + Object value = new Object() { |
| 14 | + @Override |
| 15 | + public String toString() { |
| 16 | + return "string value"; |
| 17 | + } |
| 18 | + }; |
| 19 | + |
| 20 | + PotentialAssignment assignment = PotentialAssignment.forValue(name, value); |
| 21 | + |
| 22 | + assertEquals("\"string value\" <from stringDatapoint>", assignment.getDescription()); |
| 23 | + } |
| 24 | + |
| 25 | + @Test |
| 26 | + public void shouldNotUseQuotesForNullValueDescriptions() throws CouldNotGenerateValueException { |
| 27 | + String name = "nullDatapoint"; |
| 28 | + Object value = null; |
| 29 | + |
| 30 | + PotentialAssignment assignment = PotentialAssignment.forValue(name, value); |
| 31 | + |
| 32 | + assertEquals("null <from nullDatapoint>", assignment.getDescription()); |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + public void shouldIncludeFailureInDescriptionIfToStringFails() throws CouldNotGenerateValueException { |
| 37 | + String name = "explodingValue"; |
| 38 | + Object value = new Object() { |
| 39 | + @Override |
| 40 | + public String toString() { |
| 41 | + throw new RuntimeException("Oh no!"); |
| 42 | + } |
| 43 | + }; |
| 44 | + |
| 45 | + PotentialAssignment assignment = PotentialAssignment.forValue(name, value); |
| 46 | + |
| 47 | + assertEquals("[toString() threw RuntimeException: Oh no!] <from explodingValue>", assignment.getDescription()); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + public void shouldReturnGivenValue() throws CouldNotGenerateValueException { |
| 52 | + Object value = new Object(); |
| 53 | + PotentialAssignment assignment = PotentialAssignment.forValue("name", value); |
| 54 | + assertEquals(value, assignment.getValue()); |
| 55 | + } |
56 | 56 |
|
57 | 57 | }
|
0 commit comments