* Tests for buyIceCream.
*/
@Test
public void testBuyIceCream() {
final SpeakerNPC npc = getNPC("Sam");
final Engine en = npc.getEngine();
assertTrue(en.step(player, "hi"));
assertEquals("Hi. Can I #offer you an ice cream?", getReply(npc));
assertTrue(en.step(player, "job"));
assertEquals("I sell delicious ice creams.", getReply(npc));
assertTrue(en.step(player, "offer"));
assertEquals("I sell ice cream.", getReply(npc));
assertTrue(en.step(player, "quest"));
assertEquals("Mine's a simple life, I don't need a lot.", getReply(npc));
assertTrue(en.step(player, "buy"));
assertEquals("An ice cream will cost 30. Do you want to buy it?", getReply(npc));
assertTrue(en.step(player, "no"));
assertEquals("Ok, how else may I help you?", getReply(npc));
assertTrue(en.step(player, "buy dog"));
assertEquals("Sorry, I don't sell dogs.", getReply(npc));
assertTrue(en.step(player, "buy house"));
assertEquals("Sorry, I don't sell houses.", getReply(npc));
assertTrue(en.step(player, "buy someunknownthing"));
assertEquals("Sorry, I don't sell someunknownthings.", getReply(npc));
assertTrue(en.step(player, "buy a bunch of socks"));
assertEquals("Sorry, I don't sell bunches of socks.", getReply(npc));
assertTrue(en.step(player, "buy 0 ice creams"));
assertEquals("Sorry, how many ice creams do you want to buy?!", getReply(npc));
assertTrue(en.step(player, "buy ice cream"));
assertEquals("An ice cream will cost 30. Do you want to buy it?", getReply(npc));
assertTrue(en.step(player, "no"));
assertEquals("Ok, how else may I help you?", getReply(npc));
assertTrue(en.step(player, "buy ice cream"));
assertEquals("An ice cream will cost 30. Do you want to buy it?", getReply(npc));
assertTrue(en.step(player, "yes"));
assertEquals("Sorry, you don't have enough money!", getReply(npc));
// equip with enough money to buy two ice creams
assertTrue(equipWithMoney(player, 60));
assertTrue(en.step(player, "buy three icecreams"));
assertEquals("3 ice creams will cost 90. Do you want to buy them?", getReply(npc));
assertTrue(en.step(player, "yes"));
assertEquals("Sorry, you don't have enough money!", getReply(npc));
assertTrue(en.step(player, "buy ice cream"));
assertEquals("An ice cream will cost 30. Do you want to buy it?", getReply(npc));
assertFalse(player.isEquipped("ice cream"));
assertTrue(en.step(player, "yes"));
assertEquals("Congratulations! Here is your ice cream!", getReply(npc));
assertTrue(player.isEquipped("icecream", 1));
assertTrue(en.step(player, "buy icecream"));
assertEquals("An ice cream will cost 30. Do you want to buy it?", getReply(npc));
assertTrue(en.step(player, "yes"));
assertEquals("Congratulations! Here is your ice cream!", getReply(npc));
assertTrue(player.isEquipped("icecream", 2));
assertTrue(en.step(player, "buy 0 ice creams"));
assertEquals("Sorry, how many ice creams do you want to buy?!", getReply(npc));
// buying one ice cream by answering "yes" to npc's greeting
assertTrue(equipWithMoney(player, 30));
assertTrue(en.step(player, "bye"));
assertEquals("Bye, enjoy your day!", getReply(npc));
assertTrue(en.step(player, "hi"));
assertEquals("Hi. Can I #offer you an ice cream?", getReply(npc));
assertTrue(en.step(player, "yes"));
assertEquals("An ice cream will cost 30. Do you want to buy it?", getReply(npc));
assertTrue(en.step(player, "yes"));
assertEquals("Congratulations! Here is your ice cream!", getReply(npc));
assertTrue(player.isEquipped("icecream", 3));
}