1

I have method in my controller there I use Request.InputStream. How to write a tests that will cause the method of the controller with the set by me data in Request.InputStream?

My method:

    var result = new MediaJsonResult();
            try
            {
                using (var str = new StreamReader(Request.InputStream))
                {
.....

I write Tests on NUnit

Geray Suinov
  • 3,521
  • 3
  • 16
  • 19
  • http://stackoverflow.com/questions/774204/unit-testing-in-asp-net-mvc-how-do-i-mock-a-page-request, http://stackoverflow.com/questions/321550/unit-testing-creating-a-mock-request-to-simulate-a-mvc-page-request, http://stackoverflow.com/questions/970198/how-to-mock-the-request-on-controller-in-asp-net-mvc, among others. What you're trying to do is called "mocking" or "faking" the HTTP request object for unit testing your controller. – David Aug 15 '13 at 13:37
  • possible duplicate of [Unit Testing method ASP. NET (NUnit)](http://stackoverflow.com/questions/18312485/unit-testing-method-asp-net-nunit) – Sergey Berezovskiy Aug 19 '13 at 16:32

0 Answers0