How to mock the CreateResponse extension method on HttpRequestMessage

后端 未结 2 721
时光说笑
时光说笑 2020-12-23 19:14

I\'m using ASP.Net MVC 4 RC\'s ApiController and I\'m trying to unit test a GET method.

This method uses the CreateResponse method that\'s on t

2条回答
  •  温柔的废话
    2020-12-23 19:27

    This was solved by specifying an empty configuration:

    request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
    

    I got the answer to that from here

    ASP.NET WebApi unit testing with Request.CreateResponse

提交回复
热议问题