* BAEL-2182

* refactoring
This commit is contained in:
myluckagain
2018-09-23 08:43:20 +03:00
committed by Grzegorz Piwowarek
parent 991d6937f1
commit 5e8076dddd
2 changed files with 108 additions and 0 deletions
@@ -0,0 +1,38 @@
package com.baeldung.switchstatement;
import org.junit.Test;
import org.junit.Assert;
public class SwitchStatementUnitTest {
private SwitchStatement s = new SwitchStatement();
@Test
public void whenDog_thenDomesticAnimal() {
String animal = "DOG";
Assert.assertEquals("domestic animal", s.exampleOfSwitch(animal));
}
@Test
public void whenNoBreaks_thenGoThroughBlocks() {
String animal = "DOG";
Assert.assertEquals("unknown animal", s.forgetBreakInSwitch(animal));
}
@Test(expected=NullPointerException.class)
public void whenSwitchAgumentIsNull_thenNullPointerException() {
String animal = null;
Assert.assertEquals("domestic animal", s.exampleOfSwitch(animal));
}
@Test
public void whenCompareStrings_thenByEqual() {
String animal = new String("DOG");
Assert.assertEquals("domestic animal", s.exampleOfSwitch(animal));
}
}