|
| 1 | +import org.junit.Ignore; |
| 2 | +import org.junit.Test; |
| 3 | + |
| 4 | +import static org.hamcrest.CoreMatchers.is; |
| 5 | +import static org.junit.Assert.assertThat; |
| 6 | + |
| 7 | +public class ProverbTest { |
| 8 | + |
| 9 | + @Test |
| 10 | + public void zeroWordsAreGiven() { |
| 11 | + String[] words = new String[0]; |
| 12 | + String proverb = new Proverb(words).recite(), |
| 13 | + expected = ""; |
| 14 | + |
| 15 | + assertThat(proverb, is(expected)); |
| 16 | + } |
| 17 | + |
| 18 | + @Ignore("Remove to run test") |
| 19 | + @Test |
| 20 | + public void singlePieceOfProverb() { |
| 21 | + String[] words = new String[]{"nail"}; |
| 22 | + String proverb = new Proverb(words).recite(), |
| 23 | + expected = "And all for the want of a nail."; |
| 24 | + |
| 25 | + assertThat(proverb, is(expected)); |
| 26 | + } |
| 27 | + |
| 28 | + @Ignore("Remove to run test") |
| 29 | + @Test |
| 30 | + public void twoPiecesOfProverb() { |
| 31 | + String[] words = new String[]{"nail", "shoe"}; |
| 32 | + String proverb = new Proverb(words).recite(), |
| 33 | + expected = "For want of a nail the shoe was lost.\n" + |
| 34 | + "And all for the want of a nail."; |
| 35 | + |
| 36 | + assertThat(proverb, is(expected)); |
| 37 | + } |
| 38 | + |
| 39 | + @Ignore("Remove to run test") |
| 40 | + @Test |
| 41 | + public void shortChainOfConsequences() { |
| 42 | + String[] words = new String[]{"nail", "shoe", "horse"}; |
| 43 | + String proverb = new Proverb(words).recite(), |
| 44 | + expected = "For want of a nail the shoe was lost.\n" + |
| 45 | + "For want of a shoe the horse was lost.\n" + |
| 46 | + "And all for the want of a nail."; |
| 47 | + |
| 48 | + assertThat(proverb, is(expected)); |
| 49 | + } |
| 50 | + |
| 51 | + @Ignore("Remove to run test") |
| 52 | + @Test |
| 53 | + public void fullProverb() { |
| 54 | + String[] words = new String[]{"nail", "shoe", "horse", "rider", "message", "battle", "kingdom"}; |
| 55 | + String proverb = new Proverb(words).recite(), |
| 56 | + expected = "For want of a nail the shoe was lost.\n" + |
| 57 | + "For want of a shoe the horse was lost.\n" + |
| 58 | + "For want of a horse the rider was lost.\n" + |
| 59 | + "For want of a rider the message was lost.\n" + |
| 60 | + "For want of a message the battle was lost.\n" + |
| 61 | + "For want of a battle the kingdom was lost.\n" + |
| 62 | + "And all for the want of a nail."; |
| 63 | + |
| 64 | + assertThat(proverb, is(expected)); |
| 65 | + } |
| 66 | + |
| 67 | + @Ignore("Remove to run test") |
| 68 | + @Test |
| 69 | + public void fourPiecesModernizedProverb() { |
| 70 | + String[] words = new String[]{"pin", "gun", "soldier", "battle"}; |
| 71 | + String proverb = new Proverb(words).recite(), |
| 72 | + expected = "For want of a pin the gun was lost.\n" + |
| 73 | + "For want of a gun the soldier was lost.\n" + |
| 74 | + "For want of a soldier the battle was lost.\n" + |
| 75 | + "And all for the want of a pin."; |
| 76 | + |
| 77 | + assertThat(proverb, is(expected)); |
| 78 | + } |
| 79 | + |
| 80 | +} |
0 commit comments