c# - Mocking a cotroller context asp 4.5 -


i have mock controller context in order test methods authorized. problem although try this not work because when type:

var mock = new mock<controllercontext>(); 

visual studio underlines controllercontext , says

the type or namespace not found

these usings have included in unit test class: using microsoft.visualstudio.testtools.unittesting;

    using system;     using system.web;     using system.collections.generic;     using moq;     using system.web.http.controllers;     using data.contracts;     using system.linq;     using web.api.controllers; 

any ideas how include controllercontext in msdn documentation part of system.web not seem working. great if there way mock context without using this.

i fixed reference intalling mvc package. receive following error when try this:

var mock = new mock<controllercontext>();             mock.setupget(x => x.httpcontext.user.identity.name).returns("someuser");             mock.setupget(x => x.httpcontext.request.isauthenticated).returns(true);             controller.controllercontext = mock.object;  

cannot convert system.web.mvc.controllercontext system.web.http.controllers.controllercontext

> controller.controllercontext = mock.objectt; 

controllercontext part of system.web.mvc in system.web.mvc.dll. add reference it


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -