|
@@ -0,0 +1,130 @@
|
|
1
|
+package io.zipcoder.polymorphism;
|
|
2
|
+
|
|
3
|
+import org.junit.Assert;
|
|
4
|
+import org.junit.Test;
|
|
5
|
+
|
|
6
|
+public class MainApplicationTest {
|
|
7
|
+
|
|
8
|
+ @Test
|
|
9
|
+ public void speakDogTest() {
|
|
10
|
+ //Given
|
|
11
|
+ Dog rover = new Dog();
|
|
12
|
+ String expected = "What's up dawg?";
|
|
13
|
+
|
|
14
|
+ //When
|
|
15
|
+ String actual = rover.speak();
|
|
16
|
+
|
|
17
|
+ //Then
|
|
18
|
+ Assert.assertEquals(expected, actual);
|
|
19
|
+
|
|
20
|
+ }
|
|
21
|
+
|
|
22
|
+ @Test
|
|
23
|
+ public void speakCatTest() {
|
|
24
|
+ //Given
|
|
25
|
+ Cat stripes = new Cat();
|
|
26
|
+ String expected = "How do you like meow?";
|
|
27
|
+
|
|
28
|
+ //When
|
|
29
|
+ String actual = stripes.speak();
|
|
30
|
+
|
|
31
|
+ //Then
|
|
32
|
+ Assert.assertEquals(expected, actual);
|
|
33
|
+
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ @Test
|
|
37
|
+ public void speakFrogTest() {
|
|
38
|
+ //Given
|
|
39
|
+ Frog kermit = new Frog();
|
|
40
|
+ String expected = "This code is ribbeting!";
|
|
41
|
+
|
|
42
|
+ //When
|
|
43
|
+ String actual = kermit.speak();
|
|
44
|
+
|
|
45
|
+ //Then
|
|
46
|
+ Assert.assertEquals(expected, actual);
|
|
47
|
+
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+ @Test
|
|
51
|
+ public void speakDuckTest() {
|
|
52
|
+ //Given
|
|
53
|
+ Duck donald = new Duck();
|
|
54
|
+ String expected = "You quack me up!";
|
|
55
|
+
|
|
56
|
+ //When
|
|
57
|
+ String actual = donald.speak();
|
|
58
|
+
|
|
59
|
+ //Then
|
|
60
|
+ Assert.assertEquals(expected, actual);
|
|
61
|
+
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+ @Test
|
|
65
|
+ public void dogNameTest() {
|
|
66
|
+ //Given
|
|
67
|
+ Dog rover = new Dog();
|
|
68
|
+ String newName = "Fido";
|
|
69
|
+ String expected = "Fido";
|
|
70
|
+
|
|
71
|
+ //When
|
|
72
|
+ rover.setName(newName);
|
|
73
|
+ String actual = rover.getName();
|
|
74
|
+
|
|
75
|
+ //Then
|
|
76
|
+ Assert.assertEquals(expected, actual);
|
|
77
|
+
|
|
78
|
+ }
|
|
79
|
+
|
|
80
|
+ @Test
|
|
81
|
+ public void catNameTest() {
|
|
82
|
+ //Given
|
|
83
|
+ Cat stripes = new Cat();
|
|
84
|
+ String newName = "Jingles";
|
|
85
|
+ String expected = "Jingles";
|
|
86
|
+
|
|
87
|
+ //When
|
|
88
|
+ stripes.setName(newName);
|
|
89
|
+ String actual = stripes.getName();
|
|
90
|
+
|
|
91
|
+ //Then
|
|
92
|
+ Assert.assertEquals(expected, actual);
|
|
93
|
+
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ @Test
|
|
97
|
+ public void frogNameTest() {
|
|
98
|
+ //Given
|
|
99
|
+ Frog kermit = new Frog();
|
|
100
|
+ String newName = "Mr. Frog";
|
|
101
|
+ String expected = "Mr. Frog";
|
|
102
|
+
|
|
103
|
+ //When
|
|
104
|
+ kermit.setName(newName);
|
|
105
|
+ String actual = kermit.getName();
|
|
106
|
+
|
|
107
|
+ //Then
|
|
108
|
+ Assert.assertEquals(expected, actual);
|
|
109
|
+
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+ @Test
|
|
114
|
+ public void duckNameTest() {
|
|
115
|
+ //Given
|
|
116
|
+ Duck donald = new Duck();
|
|
117
|
+ String newName = "Daffy";
|
|
118
|
+ String expected = "Daffy";
|
|
119
|
+
|
|
120
|
+ //When
|
|
121
|
+ donald.setName(newName);
|
|
122
|
+ String actual = donald.getName();
|
|
123
|
+
|
|
124
|
+ //Then
|
|
125
|
+ Assert.assertEquals(expected, actual);
|
|
126
|
+
|
|
127
|
+ }
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+}
|