title: TDD in Cart application
body: <p>So I have an academic problem of simulating a Cart service.</p>
  
  <p>A Cart supports addition of an OrderItem and another responsibility of calculating the total price of the particular cart. This is done via composition and delegation to IPricingCalculator as</p>
  
  <pre><code>public class Cart
  {
  private List&lt;OrderItem&gt; _items;
  private IPricingCalculator _pricingCalculator;
  
  public Cart(IPricingCalculator pricingCalculator);
  public addItem(OrderItem);
  
  public double totalPrice()
  {
  double price = 0.0;
  for (OrderItem orderItem: _items)
      price += _pricingCalculator.getPrice(orderItem);
  }
  
  }
  </code></pre>
  
  <p>IPricingCalculator supports the getPrice method as</p>
  
  <pre><code>public interface IPricingCalculator
  {
  double getPrice(OrderItem item);
  }
  </code></pre>
  
  <p>CustomPriceCalculator implements the IPricingCalculator interface</p>
  
  <pre><code>public class CustomCalculator implements IPricingCalculator
  {
  private List&lt;IPriceRule&gt; _priceRules;
  public double getPrice(OrderItem item); // return the price according to the first rule that matches
  }
  </code></pre>
  
  <p>Now I have implemented CustomCalculator in TDD way,
  these are some of my tests:</p>
  
  <pre><code>@Test
  public void FreeItemCostNothing();
  public void SpecialItemCostHalf();
  public void BulkPurchaseCostsQuater();
  </code></pre>
  
  <p>and so on.</p>
  
  <p>And I am pretty sure that CustomCalculator is working fine.</p>
  
  <p>But I do not understand what according to TDD should be my next step for implementing Cart, all Cart is supposed to do is manage a collection of OrderItem and fold the getPrice method on the collection. Should I have same exhaustive test suite for both the classes?</p>
  
  <p>I.e should the test of the Cart include following such tests too-</p>
  
  <pre><code>@Test
  public void TenFreeItemCostNothing();
  public void FiveSpecialItemsAndBulkPurchaseCostsHalfAndQuarter();
  </code></pre>
  
  <p>etc etc</p>
  
  <p>Thanks :)</p>