01.02.2013 Views

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

implement a test in code<br />

import org.junit.*;<br />

284 Chapter 8<br />

Below is the task we’re working on and the user story it came from. Your job is to add the next<br />

test to the TestOrderInformation class to make progress on this task.<br />

To get the rest <strong>of</strong> the<br />

OrderInformation class together,<br />

you need to add c<strong>of</strong>fee<br />

preference, gift card number,<br />

customer name, and preferred<br />

store to the order information.<br />

public class TestOrderInformation {<br />

@Test<br />

public void testCreateOrderInformationInstance() { // existing test }<br />

}<br />

}<br />

Title:<br />

Preorder your c<strong>of</strong>fee<br />

with a gift card<br />

Select your c<strong>of</strong>fee preferences<br />

from the options, enter your gift card number,<br />

name, preferred store, and click submit to get a<br />

confirmation number, remaining balance, and<br />

estimated time when it will be ready for pickup.<br />

Description:<br />

Task 1<br />

20 6<br />

Priority: Estimate:<br />

Capture order info,<br />

gift card info, and<br />

receipt info.<br />

@Test<br />

public void testOrderInformation() {<br />

OrderInformation orderInfo = new OrderInfomation();<br />

orderInfo.setCustomerName(“Dan”);<br />

orderInfo.setDrinkDescription(“Mocha cappa-latte-with-half-whip-skim-fracino”);<br />

orderInfo.setGiftCardNumber(123456);<br />

orderInfo.setPreferredStoreNumber(8675309);<br />

assertEqual(orderInfo.getCustomerName(), “Dan”);<br />

assertEqual(orderInfo.getDrinkDescription(),<br />

“Mocha cappa-latte-with-half-whip-skim-fracino”);<br />

assertEqual(orderInfo.getGiftCardNumber(), 123456);<br />

assertEqual(orderInfo.getPreferredStoreNumber(), 8675309);<br />

Download at WoweBook.Com<br />

5<br />

Our test simply creates the<br />

OrderInformation, sets each value we<br />

need to track, and then checks to<br />

make sure we get the same values out.<br />

You might want to use constants<br />

in your own code, so you don’t<br />

have any typos beween setting<br />

values and checking against the<br />

returned values (especially in<br />

those long c<strong>of</strong>fee-drink names).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!