title: Application Service Layer: Unit Tests, Integration Tests, or Both?
body: <p>I've got a bunch of methods in my application service layer that are doing things like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public void Execute(PlaceOrderOnHoldCommand command)
  {
      var order = _repository.Load(command.OrderId);
      order.PlaceOnHold();
      _repository.Save(order);
  }
  </code></pre>
  
  <p>And at present, I have a bunch of unit tests like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>[Test]
  public void PlaceOrderOnHold_LoadsOrderFromRepository()
  {
      var repository = new Mock&lt;IOrderRepository&gt;();
      const int orderId = 1;
      var order = new Mock&lt;IOrder&gt;();
      repository.Setup(r =&gt; r.Load(orderId)).Returns(order.Object);
  
      var command = new PlaceOrderOnHoldCommand(orderId);
      var service = new OrderService(repository.Object);
      service.Execute(command);
  
      repository.Verify(r =&gt; r.Load(It.Is&lt;int&gt;(x =&gt; x == orderId)), Times.Exactly(1));
  }
  
  [Test]
  public void PlaceOrderOnHold_CallsPlaceOnHold()
  {
              /* blah blah */
  }
  
  [Test]
  public void PlaceOrderOnHold_SavesOrderToRepository()
  {
              /* blah blah */
  }
  </code></pre>
  
  <p>It seems to be debatable whether these unit tests add value that's worth the effort.  I'm quite sure that the application service layer should be integration tested, though.</p>
  
  <p>Should the application service layer be tested to this level of granularity, or are integration tests sufficient?</p>