-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathGetGreetingTest.java
44 lines (38 loc) · 1.16 KB
/
GetGreetingTest.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
import org.junit.Assert;
import org.junit.Test;
/**
* @author git-leon
* @version 1.0.0
* @date 5/19/21 5:07 PM
* Used to test `AliceAndBobEngine.getGreeting`
*/
public class GetGreetingTest {
private void testGetGreeting(String input, String expected) {
// given
AliceAndBobEngine evaluator = new AliceAndBobEngine();
// when
String actual = evaluator.getGreeting(input);
// then
Assert.assertEquals(expected, actual);
}
@Test
public void testGetGreetingAlice() {
String name = "Alice";
String expected = "Hello, " + name + "!";
testGetGreeting(name, expected);
}
@Test
public void testGetGreetingBob() {
String name = "Bob";
String expected = "Hello, " + name + "!";
testGetGreeting(name, expected);
}
@Test
public void testGetGreetingStranger() {
String[] strangerNames = "Leon Dolio Kris Nobles Desa Lossie Nancy".split(" ");
for(String strangerName : strangerNames) {
String expected = "Begone, " + strangerName + "! You're a stranger!";
testGetGreeting(strangerName, expected);
}
}
}