title: How do I mock a base method from the Controller class using the NSubstitue framework
body: <p>I need a mock a method present in a base class when an Action method in the Controller class invoke it.</p>
  
  <p>Here is my Controller class below, the action method <code>Index()</code> calls the base method <code>GetNameNodeStatus()</code>. Now how can I mock the <code>GetNameNodeStatus()</code> present in the base class when the action method <code>Index</code> calls it using the Nsubstitute mocking frameworks.</p>
  
  <pre><code>using Cluster.Manager.Helper;
  using Cluster.Manager.Messages;
  using System;
  using System.Collections.Generic;
  using System.Globalization;
  using System.IO;
  using System.Linq;
  using System.Net;
  using System.Web;
  using System.Web.Mvc;
  
  namespace Cluster.Manager
  {
      public class HomeController : Controller
      {
          // GET: Home
          public ActionResult Index()
          {
              ClusterMonitoring monitoring = new ClusterMonitoring();
              string getStatus = monitoring.GetNameNodeStatus("", new Credential());
              return View();
          }
       }
  }
  </code></pre>
  
  <p>Here is my base class Clustermonitoring</p>
  
  <pre><code>namespace Cluster.Manager.Helper
  {
      public class ClusterMonitoring
      {
          public virtual string GetNameNodeStatus(string hostName, Credential credential)
          {
              return "Method Not Implemented";
          }
      }
  }
  </code></pre>
  
  <p>And here is my Test class</p>
  
  <pre><code>namespace NSubstituteControllerSupport
  {
      [TestFixture]
      public class UnitTest1
      {
  
          [Test]
          public void ValidateNameNodeStatus()
          {
              var validation = Substitute.ForPartsOf&lt;ClusterMonitoring&gt;();
              validation.When(actionMethod =&gt; actionMethod.GetNameNodeStatus(Arg.Any&lt;string&gt;(), Arg.Any&lt;Credential&gt;())).DoNotCallBase();
              validation.GetNameNodeStatus("ipaddress", new Credential()).Returns("active");
              var controllers = Substitute.For&lt;HomeController&gt;();
              controllers.Index();
          }
      }
  }
  </code></pre>