title: Instance of an object created in a method. How to mock that instance?
body: <p>I have a method in my Presenter which creates a class which contains all the user inputs, called <code>UserInputEntity</code>. It implements the interface <code>IUserInputEntity</code>. I currently have it declared as a local variable, of type <code>UserInputEntity</code>, and thus can't mock it in the following method (simplified for brevity):</p>
  
  <pre><code>public void CompletionReportNotifier(object sender, VerificationStatusEventArgs e)
  {
      _view.PermanentCsvFileVerificationCancellation = null;
  
      string logMessage;
      bool inputsVisible = false;
  
      //Mocking inputs.NumberOfErrorsFound??
      if (e.CarriedOutToCompletion != true || inputs.NumberOfErrorsFound &gt; 0)
      {
          inputsVisible = true;
          _view.VerificationCompleted = false;
          logMessage = "failed to complete operation";
      }
      else
      {
          _view.VerificationCompleted = true;
          logMessage = "Completed operation";
      }
      _view.UIUpdate(logMessage, inputsVisible);
  }
  </code></pre>
  
  <p>What is the most appropriate way to get around this? The only possible solution I can think of is to declare another method which only calls the entity classes constructor, and returns an <code>IUserInputEntity</code>. I would then change the declaration of <code>inputs</code>, in the presenter, to type <code>IUserInputEntity</code>. Would this be suitable or is there a better way?</p>
  
  <p>Below is a copy of the method where the instance of <code>inputs</code> is created currently (simplified):</p>
  
  <pre><code>private void DataVerification(Object sender, EventArgs e)
  {
      if (_view.VerifyingData != true)
      {
          inputs = new UserInputEntity(_view.DataTypeInputs, _view.ColumnNameInputs, _view.InitialRow, _view.FinalRow, _view.CurrencyPair, _view.CsvFilePath, _view.ErrorLogFilePath);
  
          // ...
  
          verification.VerifyDataTypesAsync();     
      }
      else
      {
          _view.PermanentCsvFileVerificationCancellation.Cancel();
      } 
  }
  </code></pre>