title: IHttpActionResult variable passing null in test method
body: <p>I am writing a test method for an IHttpActionresult controller. The ActionResult is not NULL and contains the required data (Customer.ID = 986574123). However in line two the variable CreatedResult is null. I want it to return the appropriate data to CreatedResult. I am also using Moq framework. Don't know if that matters. Any thoughts? If you need more data from ActionResult please comment below. Thx. </p>
  
  <p>Test Method Code:</p>
  
  <pre><code>        var CustomerRepository = new Mock&lt;ICustomerRepository&gt;();
  
          CustomerRepository.Setup(x =&gt; x.Add()).Returns(new Customer { ID = 986574123, Date = DateTime.Now});      
  
          var Controller = new CustomerController(CustomerRepository.Object, new Mock&lt;IProductRepository&gt;().Object);
          var config = new HttpConfiguration();
          var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost:38306/api/CreateCustomer");
          var route = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}");
          var routeData = new HttpRouteData(route, new HttpRouteValueDictionary { { "controller", "Customers" } });
          Controller.ControllerContext = new HttpControllerContext(config, routeData, request);
          Controller.Request = request;
          Controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
  
          IHttpActionResult ActionResult = Controller.CreateCustomer();
          // Null occurs here
          var CreatedResult = ActionResult as CreatedAtRouteNegotiatedContentResult&lt;Customer&gt;;
  </code></pre>
  
  <p>CreateCustomer Add method:</p>
  
  <pre><code>         [Route("api/createcustomer")]
           [HttpPost]
           public IHttpActionResult CreateCustomer()
           {
               Customer NewCustomer = CustomerRepository.Add();
  
               return Created(Request.RequestUri + "/" + NewCustomer.ID.ToString(), new { customerID = NewCustomer.ID });
           }
  </code></pre>
  
  <p>ActionResult Data:</p>
  
  <pre><code>-       Location    {http://localhost:38306/api/createcustomer/986574123}   System.Uri
          AbsolutePath    "/api/createcustomer/986574123" string
          AbsoluteUri "http://localhost:38306/api/createcustomer/986574123"   string
          Authority   "localhost:38306"   string
          DnsSafeHost "localhost" string
          Fragment    ""  string
          Host    "localhost" string
          HostNameType    Dns System.UriHostNameType
          IsAbsoluteUri   true    bool
          IsDefaultPort   false   bool
          IsFile  false   bool
          IsLoopback  true    bool
          IsUnc   false   bool
          LocalPath   "/api/createCustomer/986574123" string
          OriginalString  "http://localhost:38306/api/createcustomer/986574123"   string
          PathAndQuery    "/api/createCustomer/986574123" string
          Port    38306   int
          Query   ""  string
          Scheme  "http"  string
  +       Segments    {string[4]} string[]
          UserEscaped false   bool
          UserInfo    ""  string
  </code></pre>