title: C# mock unit test GraphServiceClient
body: <p>I have a problem writing my unit test in C# using Moq and xUnit.</p>
  <p>In my service I have the following code:</p>
  <pre class="lang-cs prettyprint-override"><code>var options = new TokenCredentialOptions
  {
      AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
  };
  
  var clientSecretCredential = new ClientSecretCredential(tenantId, clientId, clientSecret, options);
  var graphClient = new GraphServiceClient(clientSecretCredential);
  
  
  return (await graphClient.Users.Request().Filter($&quot;displayName eq '{mobilePhone}'&quot;).GetAsync()).FirstOrDefault();
  
  </code></pre>
  <p>But I don't know a method to mock the <code>GraphClient</code> function:</p>
  <pre class="lang-cs prettyprint-override"><code>graphClient.Users.Request().Filter($&quot;displayName eq '{mobilePhone}'&quot;).GetAsync()).FirstOrDefault();
  </code></pre>