|
| 1 | +import org.junit.Test; |
| 2 | +import org.junit.Ignore; |
| 3 | +import org.junit.Before; |
| 4 | + |
| 5 | +import static org.assertj.core.api.Assertions.assertThat; |
| 6 | + |
| 7 | +public class BottleSongTest { |
| 8 | + |
| 9 | + private BottleSong bottleSong; |
| 10 | + |
| 11 | + @Before |
| 12 | + public void setup() { |
| 13 | + bottleSong = new BottleSong(); |
| 14 | + } |
| 15 | + |
| 16 | + @Test |
| 17 | + public void firstGenericVerse() { |
| 18 | + assertThat(bottleSong.recite(10, 1)).isEqualTo( |
| 19 | + "Ten green bottles hanging on the wall,\n" + |
| 20 | + "Ten green bottles hanging on the wall,\n" + |
| 21 | + "And if one green bottle should accidentally fall,\n" + |
| 22 | + "There'll be nine green bottles hanging on the wall.\n" |
| 23 | + ); |
| 24 | + } |
| 25 | + |
| 26 | + @Ignore("Remove to run test") |
| 27 | + @Test |
| 28 | + public void lastGenericVerse() { |
| 29 | + assertThat(bottleSong.recite(3, 1)).isEqualTo( |
| 30 | + "Three green bottles hanging on the wall,\n" + |
| 31 | + "Three green bottles hanging on the wall,\n" + |
| 32 | + "And if one green bottle should accidentally fall,\n" + |
| 33 | + "There'll be two green bottles hanging on the wall.\n" |
| 34 | + ); |
| 35 | + } |
| 36 | + |
| 37 | + @Ignore("Remove to run test") |
| 38 | + @Test |
| 39 | + public void verseWithTwoBottles() { |
| 40 | + assertThat(bottleSong.recite(2, 1)).isEqualTo( |
| 41 | + "Two green bottles hanging on the wall,\n" + |
| 42 | + "Two green bottles hanging on the wall,\n" + |
| 43 | + "And if one green bottle should accidentally fall,\n" + |
| 44 | + "There'll be one green bottle hanging on the wall.\n" |
| 45 | + ); |
| 46 | + } |
| 47 | + |
| 48 | + @Ignore("Remove to run test") |
| 49 | + @Test |
| 50 | + public void verseWithOneBottle() { |
| 51 | + assertThat(bottleSong.recite(1, 1)).isEqualTo( |
| 52 | + "One green bottle hanging on the wall,\n" + |
| 53 | + "One green bottle hanging on the wall,\n" + |
| 54 | + "And if one green bottle should accidentally fall,\n" + |
| 55 | + "There'll be no green bottles hanging on the wall.\n" |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | + @Ignore("Remove to run test") |
| 60 | + @Test |
| 61 | + public void firstTwoVerses() { |
| 62 | + assertThat(bottleSong.recite(10, 2)).isEqualTo( |
| 63 | + "Ten green bottles hanging on the wall,\n" + |
| 64 | + "Ten green bottles hanging on the wall,\n" + |
| 65 | + "And if one green bottle should accidentally fall,\n" + |
| 66 | + "There'll be nine green bottles hanging on the wall.\n" + |
| 67 | + "\n" + |
| 68 | + "Nine green bottles hanging on the wall,\n" + |
| 69 | + "Nine green bottles hanging on the wall,\n" + |
| 70 | + "And if one green bottle should accidentally fall,\n" + |
| 71 | + "There'll be eight green bottles hanging on the wall.\n" |
| 72 | + ); |
| 73 | + } |
| 74 | + |
| 75 | + @Ignore("Remove to run test") |
| 76 | + @Test |
| 77 | + public void lastThreeVerses() { |
| 78 | + assertThat(bottleSong.recite(3, 3)).isEqualTo( |
| 79 | + "Three green bottles hanging on the wall,\n" + |
| 80 | + "Three green bottles hanging on the wall,\n" + |
| 81 | + "And if one green bottle should accidentally fall,\n" + |
| 82 | + "There'll be two green bottles hanging on the wall.\n" + |
| 83 | + "\n" + |
| 84 | + "Two green bottles hanging on the wall,\n" + |
| 85 | + "Two green bottles hanging on the wall,\n" + |
| 86 | + "And if one green bottle should accidentally fall,\n" + |
| 87 | + "There'll be one green bottle hanging on the wall.\n" + |
| 88 | + "\n" + |
| 89 | + "One green bottle hanging on the wall,\n" + |
| 90 | + "One green bottle hanging on the wall,\n" + |
| 91 | + "And if one green bottle should accidentally fall,\n" + |
| 92 | + "There'll be no green bottles hanging on the wall.\n" |
| 93 | + ); |
| 94 | + } |
| 95 | + |
| 96 | + @Ignore("Remove to run test") |
| 97 | + @Test |
| 98 | + public void allVerses() { |
| 99 | + assertThat(bottleSong.recite(10, 10)) |
| 100 | + .isEqualTo( |
| 101 | + "Ten green bottles hanging on the wall,\n" + |
| 102 | + "Ten green bottles hanging on the wall,\n" + |
| 103 | + "And if one green bottle should accidentally fall,\n" + |
| 104 | + "There'll be nine green bottles hanging on the wall.\n" + |
| 105 | + "\n" + |
| 106 | + "Nine green bottles hanging on the wall,\n" + |
| 107 | + "Nine green bottles hanging on the wall,\n" + |
| 108 | + "And if one green bottle should accidentally fall,\n" + |
| 109 | + "There'll be eight green bottles hanging on the wall.\n" + |
| 110 | + "\n" + |
| 111 | + "Eight green bottles hanging on the wall,\n" + |
| 112 | + "Eight green bottles hanging on the wall,\n" + |
| 113 | + "And if one green bottle should accidentally fall,\n" + |
| 114 | + "There'll be seven green bottles hanging on the wall.\n" + |
| 115 | + "\n" + |
| 116 | + "Seven green bottles hanging on the wall,\n" + |
| 117 | + "Seven green bottles hanging on the wall,\n" + |
| 118 | + "And if one green bottle should accidentally fall,\n" + |
| 119 | + "There'll be six green bottles hanging on the wall.\n" + |
| 120 | + "\n" + |
| 121 | + "Six green bottles hanging on the wall,\n" + |
| 122 | + "Six green bottles hanging on the wall,\n" + |
| 123 | + "And if one green bottle should accidentally fall,\n" + |
| 124 | + "There'll be five green bottles hanging on the wall.\n" + |
| 125 | + "\n" + |
| 126 | + "Five green bottles hanging on the wall,\n" + |
| 127 | + "Five green bottles hanging on the wall,\n" + |
| 128 | + "And if one green bottle should accidentally fall,\n" + |
| 129 | + "There'll be four green bottles hanging on the wall.\n" + |
| 130 | + "\n" + |
| 131 | + "Four green bottles hanging on the wall,\n" + |
| 132 | + "Four green bottles hanging on the wall,\n" + |
| 133 | + "And if one green bottle should accidentally fall,\n" + |
| 134 | + "There'll be three green bottles hanging on the wall.\n" + |
| 135 | + "\n" + |
| 136 | + "Three green bottles hanging on the wall,\n" + |
| 137 | + "Three green bottles hanging on the wall,\n" + |
| 138 | + "And if one green bottle should accidentally fall,\n" + |
| 139 | + "There'll be two green bottles hanging on the wall.\n" + |
| 140 | + "\n" + |
| 141 | + "Two green bottles hanging on the wall,\n" + |
| 142 | + "Two green bottles hanging on the wall,\n" + |
| 143 | + "And if one green bottle should accidentally fall,\n" + |
| 144 | + "There'll be one green bottle hanging on the wall.\n" + |
| 145 | + "\n" + |
| 146 | + "One green bottle hanging on the wall,\n" + |
| 147 | + "One green bottle hanging on the wall,\n" + |
| 148 | + "And if one green bottle should accidentally fall,\n" + |
| 149 | + "There'll be no green bottles hanging on the wall.\n" |
| 150 | + ); |
| 151 | + } |
| 152 | +} |
0 commit comments