Search the web
Sign In
New User? Sign Up
testdrivendevelopment · Test-driven Development
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
East Bound: A New Example ...   Message List  
Reply | Forward Message #31354 of 32125 |
Hi All,

*i hope this formats ok, each time I press preview it is just a single
line*

I have sent a new example to Michael Feathers in the hope that he will
upload it to the files section here.

With this example I have tried to make it more clear how to go East
whilst showing that with the introduction of a facade/adaptor you

could combine logic together to make new logic out of existing
tested classes.

For example, making a CustomerSalutationPrinter print a salutation

in text and with the injection of another class print the
salutation in XML. While keeping the responsibilities simple
and clear.

I'm not sure when the file upload will happen, so below are a few
test classes to wet your appetite.


Rgs, James.
-------------------

public class CustomersTest {

private Customers customers;
private Customer firstCustomer;
private Customer secondCustomer;
private CustomerVisitor customerVisitor;

@Test
public void shouldBeAbleToAddCustomerToCustomers() {
customers.add(firstCustomer);
assertTrue(customers.hasCustomerCount(1));
}

@Test
public void shouldBeAbleToVisitEachCustomer() {
customers.add(firstCustomer);
customers.add(secondCustomer);

customers.visitEachWith(customerVisitor);
verify(customerVisitor).visit(firstCustomer);
verify(customerVisitor).visit(secondCustomer);
}

@Before
public void setup() {
firstCustomer = mock(Customer.class);
secondCustomer = mock(Customer.class);
customerVisitor = mock(CustomerVisitor.class);
customers = new Customers();
}
}

public class CustomerPrinterTest {

private CustomerPrinter customerPrinter;
private Customer customer;
private CustomerClient customerClient;

@Test
public void shouldBeAbleToPrintVisitedCustomers() {
customerPrinter.visit(customer);
verify(customer).printOn(customerClient);
}

@Before
public void setup() {
customer = mock(Customer.class);
customerClient = mock(CustomerClient.class);
customerPrinter = new CustomerPrinter(customerClient);
}
}





[Non-text portions of this message have been removed]




Wed Jul 8, 2009 9:40 pm

jamescladd
Offline Offline
Send Email Send Email

Forward
Message #31354 of 32125 |
Expand Messages Author Sort by Date

Hi All, *i hope this formats ok, each time I press preview it is just a single line* I have sent a new example to Michael Feathers in the hope that he will ...
jamescladd
Offline Send Email
Jul 10, 2009
4:32 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help