I am trying to follow TDD in my proj but I can't get my head around how to verify I am calling a dependency correctly or even if I should be trying to verify it.  Here's the requirement:  Write an AddSalesOrderTask class that is responsible for adding an order to an ERP system.  The class can take any dependencies needed but must have an Execute method signature like this:public class AddSalesOrderTask {        public override bool Execute(OrderData input) {      throw new NotImplementedException();  }}The AddSalesOrderTask.Execute method needs to map OrderData to ERPSalesOrder and then call IERPClient.AddSalesOrder.  I have an interface to access the ERP service like so:public interface IERPClient {    void AddSalesOrder(ERPSalesOrder order);}How do I verify that the mapping is done and then passed into the client?  Should I be testing both operations in this method?  To make this testable my first thought was to introduce an IMapper interface and pass it as a dependency to AddSalesOrderTask:public interface IMapper<in TFrom, in TTo> {    void Map(TFrom source, TTo destination);}Following TDD would this be a good first test?        private AddSalesOrderTask _testObj;    [Fake, UsedImplicitly]    private IERPClient _client;    [Fake, UsedImplicitly]    private IMapper<Order, SalesOrder> _mapper;    [TestInitialize]    public void MyTestInitialize() {                Fake.InitializeFixture(this);        _testObj = new AddSalesOrderTask();    }    [TestMethod]    public void Execute_MappedSalesOrderAddedToERP() {        // Arrange        var input = new OrderData();        var salesOrder = new SalesOrder();        // Act        _testObj.Execute(input);        // Assert                    A.CallTo(() => _mapper.Map(context.Order, salesOrder))            .MustHaveHappened();        A.CallTo(() => _client.AddSalesOrder(salesOrder))            .MustHaveHappened();    }Am I thinking about this correctly?
TDD verifying dependency method invoked correctly
unit testing;tdd
If had a requirement that a SalesOrder needed to be added to an ERP system how would I do this in a TDD approach? In TDD you could start with unit tests for the mapper and the ERPClient, and afterwards add a test like yours for the AddSalesOrderTask. You can also switch the order and start with tests for AddSalesOrderTask first, especially if you want to do TDD with stepwise refinement. But the more interesting question for your AddSalesOrderTask is, as @RobertHarvey has already pointed out in his comment, if the parts work together as intended. So if you want this to develop fully with TDD, you should also write an integration test for the parts, using the real mapper and the real ERP client. Note that TDD does not necessarily mean to write only unit tests.An fully automated integration test will be more effort (and it will run much slower), since you will probably need a full test environment of your ERP system for this test, with a defined set of test data. If your ERP is a bloated monster, this can become a real pain, so you have to check if the fully automated TDD approach here is worth the additional effort, or if some (semi-)manual testing might be the better alternative. But if you think this might be working in your case, you can probably omit the unit test for your AddSalesOrderTask class (at least, as long as its responsibility is so trivial as in your case). P.S.: I guess it should be _testObj = new AddSalesOrderTask(_mapper, _client);in MyTestInitialize, you have to inject the two dependencies somewhere?