c# - WebApi Unit Test HttpContextHelper with Mock -


i have method i'm trying mock (moq) unit testing i'm having difficulty props read , mocking fails sealed class. method hung off controller , have infrastructure in place.

first here method i'm trying test.

public carresponse(common.models.car car) {     string currentaccepttype = httpcontexthelper.current.request.headers["accept"];      ....removed brevity.....  } 

i have tried inject instantiated object , work headers read can't see how set headers want??

httprequest cv = new httprequest(null, "http://localhost:24244", "/cars/_services/addnewpickup"); //so far when want add headers every property read only. cv.headers.add("qewr", "adsf"); //this fails. 

msdn

ultimately using part of larger fake "session" testing.

httpcontext.current = new httpcontext(cv, new httpresponse(null)); 

mocking of httprequest fails sealed class.

so i'm kinda stumped on how test unit of code.


Comments

Popular posts from this blog

how to do line continuation in perl debugger for entering raw multi-line text (EOT)? -

javascript - Create websocket without connecting -

sharepoint - Accessing files across a shared directory using a Windows service -