I have an MVC controller, that take JSON from the input stream. Since the type of data varies I can't just set the data as a parameter to the function.
In the unit tests, I do I set the request.inputstream?
public class ApiController : Controller
{
public async Task<JsonResult> Log()
{
var data = new System.IO.StreamReader(Request.InputStream).ReadToEnd()
var value = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.MyClass>(input);
}
}
[TestMethod()]
public void LogTest()
{
var controller = new ApiController();
// need to inject JSON code request.input stream???
var result = controller.Log();
result.Wait();
Assert.AreEqual(((dynamic)result.Result.Data).success, true);
}