|
@@ -1,7 +1,206 @@
|
1
|
1
|
package io.zipcoder.polymorphism;
|
2
|
2
|
|
|
3
|
+import org.junit.Assert;
|
|
4
|
+import org.junit.Test;
|
|
5
|
+
|
3
|
6
|
/**
|
4
|
7
|
* Created by leon on 11/6/17.
|
5
|
8
|
*/
|
|
9
|
+
|
6
|
10
|
public class MainApplicationTest {
|
|
11
|
+
|
|
12
|
+ @Test
|
|
13
|
+ public void testCatSpeak() {
|
|
14
|
+ // Given
|
|
15
|
+ Cat cat = new Cat();
|
|
16
|
+ String expectedOutput = "\"Myaaaoow.\"";
|
|
17
|
+
|
|
18
|
+ //When
|
|
19
|
+ String actualOutput = cat.speak();
|
|
20
|
+
|
|
21
|
+ Assert.assertEquals(expectedOutput, actualOutput);
|
|
22
|
+ }
|
|
23
|
+
|
|
24
|
+ @Test
|
|
25
|
+ public void testDogSpeak() {
|
|
26
|
+ // Given
|
|
27
|
+ Dog dog = new Dog();
|
|
28
|
+ String expectedOutput = "\"Bork bork!\"";
|
|
29
|
+
|
|
30
|
+ //When
|
|
31
|
+ String actualOutput = dog.speak();
|
|
32
|
+
|
|
33
|
+ Assert.assertEquals(expectedOutput, actualOutput);
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ @Test
|
|
37
|
+ public void testSnakeSpeak() {
|
|
38
|
+ // Given
|
|
39
|
+ Snake snake = new Snake();
|
|
40
|
+ String expectedOutput = "\"Ssssnek...\"";
|
|
41
|
+
|
|
42
|
+ //When
|
|
43
|
+ String actualOutput = snake.speak();
|
|
44
|
+
|
|
45
|
+ Assert.assertEquals(expectedOutput, actualOutput);
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ @Test
|
|
49
|
+ public void testCatName() {
|
|
50
|
+ // Given
|
|
51
|
+ Cat cat = new Cat();
|
|
52
|
+ String properPetName = "Fluffy";
|
|
53
|
+ String expectedOutput = "Fluffy";
|
|
54
|
+
|
|
55
|
+ // When
|
|
56
|
+ cat.setName(properPetName);
|
|
57
|
+ String actualOutput = cat.getName();
|
|
58
|
+
|
|
59
|
+ Assert.assertEquals(expectedOutput, actualOutput);
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+ @Test
|
|
63
|
+ public void testDogName() {
|
|
64
|
+ // Given
|
|
65
|
+ Dog dog = new Dog();
|
|
66
|
+ String properPetName = "Rover";
|
|
67
|
+ String expectedOutput = "Rover";
|
|
68
|
+
|
|
69
|
+ // When
|
|
70
|
+ dog.setName(properPetName);
|
|
71
|
+ String actualOutput = dog.getName();
|
|
72
|
+
|
|
73
|
+ Assert.assertEquals(expectedOutput, actualOutput);
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ @Test
|
|
77
|
+ public void testSnakeName() {
|
|
78
|
+ // Given
|
|
79
|
+ Snake snake = new Snake();
|
|
80
|
+ String properPetName = "Noodle";
|
|
81
|
+ String expectedOutput = "Noodle";
|
|
82
|
+
|
|
83
|
+ // When
|
|
84
|
+ snake.setName(properPetName);
|
|
85
|
+ String actualOutput = snake.getName();
|
|
86
|
+
|
|
87
|
+ Assert.assertEquals(expectedOutput, actualOutput);
|
|
88
|
+ }
|
|
89
|
+
|
|
90
|
+ @Test
|
|
91
|
+ public void testCatType() {
|
|
92
|
+ // Given
|
|
93
|
+ Cat cat = new Cat();
|
|
94
|
+ String petType = "cat";
|
|
95
|
+ String expectedOutcome = "cat";
|
|
96
|
+
|
|
97
|
+ // When
|
|
98
|
+ cat.setType(petType);
|
|
99
|
+ String actualOutput = cat.getType();
|
|
100
|
+
|
|
101
|
+ Assert.assertEquals(expectedOutcome, actualOutput);
|
|
102
|
+ }
|
|
103
|
+
|
|
104
|
+ @Test
|
|
105
|
+ public void testDogType() {
|
|
106
|
+ // Given
|
|
107
|
+ Dog dog = new Dog();
|
|
108
|
+ String petType = "dog";
|
|
109
|
+ String expectedOutcome = "dog";
|
|
110
|
+
|
|
111
|
+ // When
|
|
112
|
+ dog.setType(petType);
|
|
113
|
+ String actualOutput = dog.getType();
|
|
114
|
+
|
|
115
|
+ Assert.assertEquals(expectedOutcome, actualOutput);
|
|
116
|
+ }
|
|
117
|
+
|
|
118
|
+ @Test
|
|
119
|
+ public void testSnakeType() {
|
|
120
|
+ // Given
|
|
121
|
+ Snake snake = new Snake();
|
|
122
|
+ String petType = "snake";
|
|
123
|
+ String expectedOutcome = "snake";
|
|
124
|
+
|
|
125
|
+ // When
|
|
126
|
+ snake.setType(petType);
|
|
127
|
+ String actualOutput = snake.getType();
|
|
128
|
+
|
|
129
|
+ Assert.assertEquals(expectedOutcome, actualOutput);
|
|
130
|
+ }
|
|
131
|
+
|
|
132
|
+ @Test
|
|
133
|
+ public void testLowerCase() {
|
|
134
|
+ // Given
|
|
135
|
+ String petType = "Cat";
|
|
136
|
+ String expectedOutput = "cat";
|
|
137
|
+
|
|
138
|
+ // When
|
|
139
|
+ String actualOutput = petType.toLowerCase();
|
|
140
|
+
|
|
141
|
+ Assert.assertEquals(expectedOutput, actualOutput);
|
|
142
|
+ }
|
|
143
|
+
|
|
144
|
+ @Test
|
|
145
|
+ public void testLowerCase1() {
|
|
146
|
+ // Given
|
|
147
|
+ String petType = "CAT";
|
|
148
|
+ String expectedOutput = "cat";
|
|
149
|
+
|
|
150
|
+ // When
|
|
151
|
+ String actualOutput = petType.toLowerCase();
|
|
152
|
+
|
|
153
|
+ Assert.assertEquals(expectedOutput, actualOutput);
|
|
154
|
+ }
|
|
155
|
+
|
|
156
|
+ @Test
|
|
157
|
+ public void testCapitalizePetName() {
|
|
158
|
+ // Given
|
|
159
|
+ String petName = "fluffy";
|
|
160
|
+ String expectedOutput = "Fluffy";
|
|
161
|
+
|
|
162
|
+ //When
|
|
163
|
+ String actualOutput = Console.capitalizePetName(petName);
|
|
164
|
+
|
|
165
|
+ Assert.assertEquals(expectedOutput, actualOutput);
|
|
166
|
+ }
|
|
167
|
+
|
|
168
|
+ @Test
|
|
169
|
+ public void testCapitalizePetName1() {
|
|
170
|
+ // Given
|
|
171
|
+ String petName = "flUFfy";
|
|
172
|
+ String expectedOutput = "Fluffy";
|
|
173
|
+
|
|
174
|
+ // When
|
|
175
|
+ String actualOutput = Console.capitalizePetName(petName);
|
|
176
|
+
|
|
177
|
+ Assert.assertEquals(expectedOutput, actualOutput);
|
|
178
|
+ }
|
|
179
|
+
|
|
180
|
+ @Test
|
|
181
|
+ public void testCapitalizePetName2() {
|
|
182
|
+ // Given
|
|
183
|
+ String petName = "lil seBastIAN";
|
|
184
|
+ String expectedOutput = "Lil Sebastian";
|
|
185
|
+
|
|
186
|
+ // When
|
|
187
|
+ String actualOutput = Console.capitalizePetName(petName);
|
|
188
|
+
|
|
189
|
+ Assert.assertEquals(expectedOutput, actualOutput);
|
|
190
|
+ }
|
|
191
|
+
|
|
192
|
+ @Test
|
|
193
|
+ public void testCapitalizePetName3() {
|
|
194
|
+ // Given
|
|
195
|
+ String petName = "jugemu jugEmu goko no surikire kaijARisuigyo no SUIGyomatsu unraimatsu furaimatsu ku neru tokoro ni sumu tokoro yabura koji no bura koji paipo-paipo paipo no shuringan shuringan no gurindai gurindai no ponpokopi no ponpokona no chokyumei no chosuKE";
|
|
196
|
+ String expectedOutput = "Jugemu Jugemu Goko No Surikire Kaijarisuigyo No Suigyomatsu Unraimatsu Furaimatsu Ku Neru Tokoro Ni Sumu Tokoro Yabura Koji No Bura Koji Paipo-paipo Paipo No Shuringan Shuringan No Gurindai Gurindai No Ponpokopi No Ponpokona No Chokyumei No Chosuke";
|
|
197
|
+
|
|
198
|
+ // When
|
|
199
|
+ String actualOutput = Console.capitalizePetName(petName);
|
|
200
|
+
|
|
201
|
+ Assert.assertEquals(expectedOutput, actualOutput);
|
|
202
|
+ }
|
7
|
203
|
}
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|