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]