title: Passing the null object from a test method
body: <p>I have a class <code>Class1</code>, which has a constructor and few methods. For these methods I'm writing the unit test cases using MSTest. The class looks like this.</p>
  
  <pre><code>class Class1
  {
      Order order = new Order(); // there is an class Order
      public Class1(Order _order)
      {
          order = _order;
      }
      public virtual async Task&lt;bool&gt; GetData()
      {
          if(order != null)
          {
              //do something
          }
          else
          {
              // do something else
          }
      }
  }
  </code></pre>
  
  <p>Now, I have to write 2 test cases for this GetData() method, when which tests if block and one which tests the else block. I was able to test the if block successfully, but not able to test the else block. The test method which I'm trying to write is as below.</p>
  
  <pre><code>[TestMethod()]
  public void GetDataTest()
  {
      Order order = new Order();
      order = null;
      var mockService = new Mock&lt;Class1&gt;(order)
      {
          CallBase = true
      };
      var result = await mockService.Object.GetData(); // error thrown from here
      Assert.IsFalse(result);
  }
  </code></pre>
  
  <p>What I'm trying to do is set the order object to null and pass the null object to the constructor.But this is throwing some error "Ambiguous match found". Clearly passing the null value is not working here. So can anyone tell me any other work around to test the else block.  </p>
  
  <p>PS: I need to test both if and else block so that it is included in the code coverage. </p>