title: Moq setting method return value
body: <p>I have the below class, and I am trying to test the method AddRecordToQueue. </p>
  
  <p>I am using Moq to mock the result of the the AddToQueue method within the AddRecordToQueue method. </p>
  
  <p>The AddToQueue method returns a boolean, so i am trying to mock the result with a true value</p>
  
  <pre><code>public class Test
  {
      private readonly IRabbitMqConnection rabbitMqConnection;
  
      public Test(IRabbitMqConnection rabbitMqConnection)
      {
          this.rabbitMqConnection = rabbitMqConnection;
  
      }
  
      public bool AddRecordToQueue(string messageExchange, object data)
      {
          var jsonified = JsonConvert.SerializeObject(data);
          var customerBuffer = Encoding.UTF8.GetBytes(jsonified);
          var result = this.rabbitMqConnection.AddToQueue(customerBuffer, messageExchange);
          return result;
      }
  }
  </code></pre>
  
  <p>My test class looks like the below.</p>
  
  <pre><code>[TestClass]
  public class TestCon
  {
      [TestMethod]
      public void MockTest()
      {
          Moq.Mock&lt;IRabbitMqConnection&gt; rabbitConection = new Moq.Mock&lt;IRabbitMqConnection&gt;();
  
          var draftContactsManager = new Test(rabbitConection.Object);
  
          rabbitConection.Setup(e =&gt; e.AddToQueue(null, string.Empty)).Returns((bool res) =&gt; true);
  
          var result = draftContactsManager.AddRecordToQueue("someExchange", null);
  
          Assert.IsTrue(result);
      }
  }
  </code></pre>
  
  <p>I cant seem to set the moq result as true. Can anyone advise what I am missing</p>
  
  <p>thanks</p>