title: MOQing a controller in MVC
body: <p>I have the following controller</p>
  
  <pre><code> public class ProviderController : Controller
  {
      private static readonly IProviderRepository _repository = new ProviderRepository();
      private static readonly Ilogger Logger = new Logger();     
  
      [HttpPost]
      public ActionResult CreateProvider(Provider provider)
      {
          try
          {
              int providerCreationSuccessful = _repository.CreateProvider(provider);
              if (providerCreationSuccessful == 1)
                  TempData["userIntimation"] = "Provider Registered Successfully";
  
              return RedirectToAction("ShowTheListOfProviders");
          }
          catch (Exception Ex)
          {
              Logger.Error(Ex.Message);
              return View("Error");
          }
      }
   }
  </code></pre>
  
  <p>The IProviderRepository looks like this.</p>
  
  <pre><code>public interface IProviderRepository
  {
      List&lt;Provider&gt; GetListofProviders();
  
      Provider GetSingleProviderDetails(int ProviderID);
  
      int CreateProvider(Provider provider);
  
      int DeleteProvider(int ProviderID);
  
      int UpdateProviderDetails(Provider provider);
  }
  </code></pre>
  
  <p>I have to MOQ the controller apparently.I am guessing that means I ahve to MPOQ the methods.So,I created a test project with the following method.</p>
  
  <pre><code> public class ProviderControllerTests
  {
      Provider _provider;
      Mock&lt;IProviderRepository&gt; mockProviderRepository;
  
      [TestInitialize]
      public void InitializeTestData()
      {
          _provider = new Provider();
          mockProviderRepository = new Mock&lt;IProviderRepository&gt;();
      }
    [TestMethod()]
      public void repository_CreateProviderTest()
      {
          //Act
          mockProviderRepository.Setup(provider =&gt; provider.CreateProvider(_provider)).Returns(1);
          //Assert
          throw new NotImplementedException();
      }
  }
  </code></pre>
  
  <p>Could some one guide me on what exactly I need to mock here.I feel like I am a little in over my head.</p>