// Test case 6 : Insert 2 quarters and turn crank and Insert 2 quarters again and turn crank // Chenking to see if multiple time inserting 50 cents dispences the gumball @Test public void testCountOfGumballsInSlot() { gumballM1.insertQuarter(); gumballM1.insertQuarter(); gumballM1.turnCrank(); gumballM1.insertQuarter(); gumballM1.insertQuarter(); gumballM1.turnCrank(); assertEquals(true, gumballM1.isGumballInSlot()); gumballM1.takeGumballFromSlot(); assertEquals(false, gumballM1.isGumballInSlot()); }
// Test case 5 : Inserting more then 50 cents and checking for change and Gumball in slot @Test public void testFiftyPlusSecond() { gumballM1.insertDime(); gumballM1.insertDime(); gumballM1.insertDime(); gumballM1.insertQuarter(); gumballM1.turnCrank(); assertEquals(true, gumballM1.isGumballInSlot()); }
// Test case 1: insert 1 quarter, insert 1 dime and 3 nickel = 50Cents : +ve test case @Test public void testQDNNNHappy() { gumballM1.insertQuarter(); gumballM1.insertDime(); gumballM1.insertNickel(); gumballM1.insertNickel(); gumballM1.insertNickel(); gumballM1.turnCrank(); assertEquals(true, gumballM1.isGumballInSlot()); }
// Test Case 9: Insert 50 cents first but remove some amount before // turning crank then check to see if gumball is dispenced or not : -ve test case @Test public void TestQDDDDEjectQNegative() { gumballM1.insertQuarter(); gumballM1.insertDime(); gumballM1.insertDime(); gumballM1.insertDime(); gumballM1.ejectQuarter(); gumballM1.turnCrank(); assertEquals(false, gumballM1.isGumballInSlot()); }
// Test case 4 :Try to take a dispensed gumball and crank the machine again without inserting any // coin @Test public void testTakeGumballAndCrankAgainWithoutInsertingAnyCoinQDNNN() { gumballM1.insertQuarter(); gumballM1.insertDime(); gumballM1.insertNickel(); gumballM1.insertNickel(); gumballM1.insertNickel(); gumballM1.turnCrank(); gumballM1.takeGumballFromSlot(); soldState.turnCrank(); assertEquals(false, gumballM1.isGumballInSlot()); }
// Test case 8 : Testing eject method and get cents back method @Test public void testEjectAndCentsBackCheck() { gumballM1.insertQuarter(); gumballM1.ejectNickel(); gumballM1.insertDime(); gumballM1.insertDime(); gumballM1.insertQuarter(); // assertEquals(15, gumballM1.getChange()); assertEquals(false, gumballM1.isGumballInSlot()); gumballM1.turnCrank(); assertEquals(true, gumballM1.isGumballInSlot()); }
// Test case 3 : Checking whether gumball will be dispensed before inserting any coin @Test public void testCrankWithoutInsertingAnyCoin() { gumballM1.turnCrank(); assertEquals(false, gumballM1.isGumballInSlot()); }
// Test Case 7 : Negative test case : No gumball should return when less then 50 cents inserted // and turned crank @Test public void testAddOneQuarterNeg() { gumballM1.insertQuarter(); gumballM1.turnCrank(); assertEquals(false, gumballM1.isGumballInSlot()); }