title: How to setup Mock of IConfigurationRoot to return value
body: <p>I have used IConfigurationRoute to access a directory like this.</p>
  
  <pre><code>if (type == "error") directory = _config.GetValue&lt;string&gt;("Directories:SomeDirectory");
  </code></pre>
  
  <p>_config is IConfigurationRoot injected in the constructor.</p>
  
  <p>I tried the following way to mock it.</p>
  
  <pre><code>        var mockConfigurationRoot = new Mock&lt;IConfigurationRoot&gt;();
          mockConfigurationRoot.Setup(c =&gt; c.GetValue&lt;string&gt;("Directories: SomeDirectory"))
              .Returns("SomeDirectory")
              .Verifiable();
          var config = mockConfigurationRoot.Object;
  </code></pre>
  
  <p>The issue is while running the test Xunit throws the exception saying </p>
  
  <blockquote>
    <p>"System.NotSupportedException : Expression references a method that
    does not belong to the mocked object"</p>
  </blockquote>
  
  <p>How can I solve this issue?</p>