Question: public void test_01() { /* Create a new item with no storage. * No error checking is needed on the title of item. */ Item
public void test_01() {
/* Create a new item with no storage.
* No error checking is needed on the title of item.
*/
Item i1 = new Item("iPad Pro");
assertEquals("iPad Pro", i1.getTitle());
assertEquals(0, i1.getAmount());
/* When there was no error,
* the item's info summarizes its title and current amount.
* Note the spaces after the colon and before the opening parenthesis.
*/
assertEquals("Item: iPad Pro (0)", i1.getInfo());
}
@Test
public void test_02() {
Item i1 = new Item("iPad Pro");
/* Amount for increase must be positive. */
i1.increaseAmount(0);
/* When the last-invoked mutator resulted in an error,
* there should be no change on the item's title or amount,
* and the item's info should be set to the corresponding error message.
*
* Note. Invoking accessors does not modify the info of the item.
* Only invoking mutators may.
*/
assertEquals("Error: non-positive amount 0", i1.getInfo());
i1.increaseAmount(-3);
assertEquals("Error: non-positive amount -3", i1.getInfo());
assertEquals(0, i1.getAmount());
}
no library classes please
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
