title: How to use Moq in unit test that calls another method in same class
body: <p>Hi I am new to Moq framework and have some questions about how to use it. I will give an example and hope for answers.</p>
  
  <p>I have two classes, an interface and and an implementation:</p>
  
  <pre><code>public class Vehicle{
     public string RegistrationNumber {get; set;}
     public long VehicleIdentifier { get; set; }
     public Tyre TyreSpecification { get; set; }
  }
  
  public class Tyre {
      public long NumberOfTyres {get; set;}
      public long TyreSize { get; set;}
  }
  
  public interface ISelecter {
     Vehicle GetVehicleByRegistrationNumber(string registrationNumber);
     Tyre GetTyreSpecification(long vehicleIdentifier);
  }
  
  public class Selecter : ISelecter
  {
      public Vehicle GetVehicleByRegistrationNumber(string registrationNumber)
      {
          var vehicle = 'Database will give us the vehicle specification';
  
          //Then we do things with the vehicle object
  
          //Get the tyre specification
          vehicle.TyreSpecification = GetTyreSpecification(vehicle.VehicleIdentifier);
  
          return vehicle;
  
      }
  
      public Tyre GetTyreSpecification(long vehicleIdentifier)
      {
           var tyre = 'external manufacture system gets the tyre specification';
  
           //Then do thing with the tyre before returning the object
  
  
           return tyre;
      }
  }
  </code></pre>
  
  <p>I want to write two tests for those methods. The problem is when I write the test for <code>GetVehicleByRegistrationNumber</code> I do not know how to mock the method call to <code>GetTyreSpecification</code>.</p>
  
  <p>The test methods look like this:</p>
  
  <pre><code>[TestClass]
  public class SelecterTest
  {
      [TestMethod]
      public void GetTyreSpecification_test()
      {
          //Arrange
          var tyre = new Tyre { NumberOfTyres = 4, TyreSize = 18 };
  
          var mockSelecter = new Mock&lt;ISelecter&gt;();
          mockSelecter.SetUp(s=&gt;s.GetTyreSpecification(It.IsAny&lt;long&gt;())).Returns(tyre);
  
          //Act
          var tyreSpec = mockSelecter.Object.GetTyreSpecification(123456);
  
          //Assert
          Assert.IsTrue(tyreSpec.NumberOfTyres == 4 &amp;&amp; tyreSpec.TyreSize == 18);
      }
  
      [TestMethod]
      public void GetVehicleByRegistrationNumber_test()
      {
          //Arrange
          var vehicle= new Vehicle { VehicleIdentifier = 123456, RegistrationNumber = ABC123, TyreSpecification = new Tyre { Tyresize = 18, NumberOfTyres = 4 }};
  
          var mockSelecter = new Mock&lt;ISelecter&gt;();
          mockSelecter.SetUp(s=&gt;s.GetVehicleByRegistrationNumber(It.IsAny&lt;string&gt;     ())).Returns(vehicle);
  
          //Act
          var vehicle = mockSelecter.Object.GetVehicleByregistrationNumber(123456);
  
          //Assert
          Assert.IsTrue(vehicle.Registrationnumber == "ABC123";
      }
  }
  </code></pre>
  
  <p>In the test method <code>GetVehicleByRegistrationNumber_test</code> how do I mock the call to <code>getTyreSpecification</code>?</p>