123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
-
-
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- public class BonusTest
- {
- private Bonus bonus;
-
- @Before
- public void setUp(){
- bonus = new Bonus();
- }
-
- @Test
- public void testFactorialBase(){
- //Given
- int number = 1;
- int expected = 1;
-
- //When
- int actual = bonus.factorial(number);
-
- //Then
- assertEquals(expected, actual);
-
- }
-
- @Test
- public void testFactorialOfSmallNumber(){
- //Given
- int number = 3;
- int expected = 6;
-
- //When
- int actual = bonus.factorial(number);
-
- //Then
- assertEquals(expected, actual);
-
- }
-
- @Test
- public void testFactorialOfBigNumber(){
- //Given
- int number = 6;
- int expected = 720;
-
- //When
- int actual = bonus.factorial(number);
-
- //Then
- assertEquals(expected, actual);
-
- }
-
- @Test
- public void testAcronymBasic() {
- //Given
- String phrase = "Portable Network Graphics";
- String expected = "PNG";
-
- //When
- String actual = bonus.acronym(phrase);
-
- //Then
- assertEquals(expected, actual);
- }
-
- @Test
- public void testAcronymBasicLowercaseWords() {
- //Given
- String phrase = "Ruby on Rails";
- String expected = "ROR";
-
- //When
- String actual = bonus.acronym(phrase);
-
- //Then
- assertEquals(expected, actual);
- }
-
- @Test
- public void testAcronymBasicPunctuation() {
- //Given
- String phrase = "First In, First Out";
- String expected = "FIFO";
-
- //When
- String actual = bonus.acronym(phrase);
-
- //Then
- assertEquals(expected, actual);
- }
-
- @Test
- public void testAcronymBasicNonAcronymAllCapsWord() {
- //Given
- String phrase = "GNU Image Manipulation Program";
- String expected = "GIMP";
-
- //When
- String actual = bonus.acronym(phrase);
-
- //Then
- assertEquals(expected, actual);
- }
-
-
-
-
- @Test
- public void testEncryptWithTheFirstAlphabet(){
- //Given
- String word = "apple";
- String expected = "dssoh";
-
- //When
- String actual = bonus.encrypt(word);
-
- //Then
- assertEquals(expected, actual);
- }
-
- @Test
- public void testEncryptWithTheLastLetters(){
- //Given
- String word = "wxyz";
- String expected = "zabc";
-
- //When
- String actual = bonus.encrypt(word);
-
- //Then
- assertEquals(expected, actual);
- }
-
-
-
- }
|