Skip to content

Commit b4dcec4

Browse files
committed
Added tests for multiton pattern
1 parent a0af0a1 commit b4dcec4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.iluwatar.multiton;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.assertEquals;
6+
import static org.junit.Assert.assertNotNull;
7+
import static org.junit.Assert.assertSame;
8+
9+
/**
10+
* Date: 12/22/15 - 22:28 AM
11+
*
12+
* @author Jeroen Meulemeester
13+
*/
14+
public class NazgulTest {
15+
16+
/**
17+
* Verify if {@link Nazgul#getInstance(NazgulName)} returns the correct Nazgul multiton instance
18+
*/
19+
@Test
20+
public void testGetInstance() {
21+
for (final NazgulName name : NazgulName.values()) {
22+
final Nazgul nazgul = Nazgul.getInstance(name);
23+
assertNotNull(nazgul);
24+
assertSame(nazgul, Nazgul.getInstance(name));
25+
assertEquals(name, nazgul.getName());
26+
}
27+
}
28+
29+
}

0 commit comments

Comments
 (0)