-
Notifications
You must be signed in to change notification settings - Fork 0
/
FrontendDeveloperTests.java
99 lines (81 loc) · 2.79 KB
/
FrontendDeveloperTests.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
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
// --== CS400 File Header Information ==--
// Name: Karam Dilip Gursahani
// Email: kdgursahani@wisc.edu
// Team: EB
// TA: Sujitha Perumal
// Lecturer: Florian Heimerl
// Notes to Grader: <optional extra notes>
/*** JUnit imports ***/
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; // Do NOT use org.junit.Test, will cause BeforeEach to error out!
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* This class runs the tests associated with the Frontend Developer's Code
* @author karam
*
*/
public class FrontendDeveloperTests {
protected TextUITester tester = null;
protected CampusMapperFrontend frontEnd = null;
protected String output;
/**
* Creates an instance of the frontend of the application before each test.
*/
@BeforeEach
public void createInstance() {
frontEnd = new CampusMapperFrontend();
}
/**
* This method tests to see that the program reacts correctly when fed fewest doors argument
*/
@Test
public void validOnThree() {
tester = new TextUITester("3\n\nEXIT\n");
frontEnd.runCommandLoop();
output = tester.checkOutput();
assertTrue(output.contains("The path with the fewest doors is C - A - D"));
}
/**
* This method tests to see that the program reacts correctly when fed shortest path argument
*/
@Test
public void validOnOne() {
tester = new TextUITester("1\n\nEXIT\n");
frontEnd.runCommandLoop();
output = tester.checkOutput();
assertTrue(output.contains("The shortest path is A - D"));
System.out.println(output);
}
/**
* This method tests to see that the program reacts correctly when fed all paths argument
*/
@Test
public void validOnTwo() {
tester = new TextUITester("2\n\nEXIT\n");
frontEnd.runCommandLoop();
output = tester.checkOutput();
assertTrue(output.contains(
"These are the paths you could take with the time required to traverse them: A - D: 5 minutes| C - A - D: 11 minutes|"));
}
/**
* This method tests to see that the program reacts correctly when fed an invalid argument
*/
@Test
public void invalid() {
tester = new TextUITester("45\n\nEXIT\n");
frontEnd.runCommandLoop();
output = tester.checkOutput();
assertTrue(output.contains("That is not a valid option, you should either select 1,2, or 3."));
}
//
/**
* This method tests to see that the program reacts correctly when the user requests to exit
*/
@Test
public void exit() {
tester = new TextUITester("2\n\n1\n\n3\n\nEXIT\n");
frontEnd.runCommandLoop();
output = tester.checkOutput();
assertTrue(output.contains("Goodbye!"));
}
}