public void GetOrdersByCustomerId_CustomerIdProvided_OrderQueryIsBeingExecuted() { var orderDataContext = new OrderDataContext(); var orderQueries = new Mock <IOrderQueries>(); var sqlConnectionFactory = new Mock <ISqlConnectionFactory>(); var sqlConnection = new Mock <IDbConnection>(); var dbTransaction = new Mock <IDbTransaction>(); sqlConnection.Setup(e => e.BeginTransaction()).Returns(dbTransaction.Object); sqlConnectionFactory.Setup(e => e.GetSqlConnection(It.IsAny <string>())).Returns(sqlConnection.Object); OrderDataContext.SqlConnectionFactory = sqlConnectionFactory.Object; OrderDataContext.OrderQueries = orderQueries.Object; var anyId = 1; orderDataContext.GetOrdersByCustomerId(anyId); orderQueries.Verify(e => e.GetOrdersByCustomerId(It.IsAny <IDbConnection>(), anyId), Times.Exactly(1)); }