title: Moq.Mock Exception with invocation failed with mock behavior strict
body: <p>I am new to Moq framework and I have writtern a test method but I am getting the below error. I couldn't find where I have missed.</p>
  
  <p>Can some one please let me know how can i correct the below error?</p>
  
  <hr>
  
  <blockquote>
    <p>An exception of type 'Moq.MockException' occurred in Moq.dll but was
    not handled in user code</p>
    
    <p>Additional information: IResponseMessage.ReadContentAsString()
    invocation failed with mock behavior Strict.</p>
    
    <p>All invocations on the mock must have a corresponding setup.</p>
  </blockquote>
  
  <p><strong>Execp.cs</strong></p>
  
  <pre><code>public Execp(IResponseMessage msg)  
  {
  
      this.StatusCode = msg.StatusCode;//*getting exception here while running **method 1***
      this.ReadContentAsString = msg.ReadContentAsString();//*getting exception here while running **method 2***
  
  
  }
  </code></pre>
  
  <p><strong>My test Methods</strong></p>
  
  <p><strong>Method 1</strong></p>
  
  <pre><code>[TestMethod()]        
  public void TestFail()
  {
  
      int employeeId = 0;
  
      DataModel.Employee.Get.Employee employee= new DataModel.Employee.Get.Employee();
      string url = string.Format("api/1/somename/{0}", employeeId);
  
      restClient
          .Setup(x =&gt; x.Get(url))
          .Returns(responseMessage.Object);
  
      responseMessage.SetupGet(x =&gt; x.IsSuccessStatusCode).Returns(false);
  
      var client = new account(clientFactory.Object, serverUri, moqLogged.Object);
      var result = client.GetEmployee(employeeId);
      Assert.AreEqual(result, null);
  
      client.Dispose();
      moqFactory.VerifyAll();
  }
  </code></pre>
  
  <p><strong>Method 2</strong></p>
  
  <pre><code>[TestMethod()]
  public void TestBadRequest()
  {
  
     var httpStatusCode = System.Net.HttpStatusCode.BadRequest;
  
      string employeeName = "Test Name";
      int teamLeaderId= 1;
      string url = string.Format("api/1/somename/{0}/teammember", teamLeaderId);
      DataModel.Group.Post.TeamMember employee= new DataModel.Group.Post.teamMember();
  
      UserResponse userResponse = new UserResponse();
  
      restClient
          .Setup(x =&gt; x.PostAsJson(url, It.IsAny&lt;DataModel.Employee.Post.TeamMember&gt;()))
          .Returns(responseMessage.Object);
  
      responseMessage.SetupGet(x =&gt; x.IsSuccessStatusCode).Returns(false);
      responseMessage.SetupGet(x =&gt; x.StatusCode).Returns(httpStatusCode);
  
      var client = new AcronisAccountManagementClient(clientFactory.Object, serverUri, moqLogged.Object);
  
      var result = client.CreateEmployee(employee, teamLeaderId);
      Assert.AreEqual(result.statusCode, httpStatusCode);
  
      client.Dispose();
      moqFactory.VerifyAll();
  }
  </code></pre>