本文整理汇总了C#中System.Web.HttpContextBase.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContextBase.Stub方法的具体用法?C# HttpContextBase.Stub怎么用?C# HttpContextBase.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpContextBase
的用法示例。
在下文中一共展示了HttpContextBase.Stub方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Context
protected override void Context()
{
AccountService = MockRepository.GenerateStub<IAccountService>();
Identity = new FakeIdentity(Username);
_user = new FakePrincipal(Identity, null);
HttpRequest = MockRepository.GenerateStub<HttpRequestBase>();
HttpContext = MockRepository.GenerateStub<HttpContextBase>();
HttpContext.Stub(x => x.Request).Return(HttpRequest);
HttpContext.User = _user;
_httpResponse = MockRepository.GenerateStub<HttpResponseBase>();
_httpResponse.Stub(x => x.Cookies).Return(new HttpCookieCollection());
HttpContext.Stub(x => x.Response).Return(_httpResponse);
Logger = MockRepository.GenerateStub<ILogger>();
WebAuthenticationService = MockRepository.GenerateStub<IWebAuthenticationService>();
MappingEngine = MockRepository.GenerateStub<IMappingEngine>();
AccountCreator = MockRepository.GenerateStub<IAccountCreator>();
AccountController = new AccountController(AccountService, Logger, WebAuthenticationService, MappingEngine, null, AccountCreator);
AccountController.ControllerContext = new ControllerContext(HttpContext, new RouteData(), AccountController);
}
示例2: HttpContextMock
public HttpContextMock()
{
_contextBase = MockRepository.GenerateStub<HttpContextBase>();
_requestBase = MockRepository.GenerateStub<HttpRequestBase>();
_responseBase = MockRepository.GenerateStub<HttpResponseBase>();
_sessionStateBase = MockRepository.GenerateStub<HttpSessionStateBase>();
_serverUtilityBase = MockRepository.GenerateStub<HttpServerUtilityBase>();
_contextBase.Stub(x => x.Request).Return(_requestBase);
_contextBase.Stub(x => x.Response).Return(_responseBase);
_contextBase.Stub(x => x.Session).Return(_sessionStateBase);
_contextBase.Stub(x => x.Server).Return(_serverUtilityBase);
}
示例3: SetUp
public void SetUp()
{
theHttpContext = MockRepository.GenerateMock<HttpContextBase>();
theRequestContext = new RequestContext(theHttpContext, new RouteData());
theHttpRequest = MockRepository.GenerateMock<HttpRequestBase>();
theHttpContext.Stub(x => x.Request).Return(theHttpRequest);
theHttpResponse = MockRepository.GenerateMock<HttpResponseBase>();
theHttpContext.Stub(x => x.Response).Return(theHttpResponse);
theArguments = new AspNetServiceArguments(theRequestContext);
}
示例4: SetUp
public virtual void SetUp()
{
mockRequest = MockRepository.GenerateStub<HttpRequestBase>();
mockContext = MockRepository.GenerateStub<HttpContextBase>();
mockSession = new MockSession();
formCollection = new NameValueCollection();
querystringCollection = new NameValueCollection();
mockRequest.Stub(x => x.Form).Return(formCollection);
mockRequest.Stub(x => x.QueryString).Return(querystringCollection);
mockContext.Stub(x => x.Request).Return(mockRequest);
mockContext.Stub(x => x.Session).Return(mockSession);
}
示例5: SetUp
public void SetUp()
{
theHttpContext = MockRepository.GenerateMock<HttpContextBase>();
theHttpSession = new StubSession();
theHttpContext.Stub(x => x.Session).Return(theHttpSession);
theSessionState = new SimpleSessionState(theHttpContext);
}
示例6: Context
protected override void Context()
{
_user = new FakePrincipal(new FakeIdentity(Username), null);
HttpRequest = MockRepository.GenerateStub<HttpRequestBase>();
HttpContext = MockRepository.GenerateStub<HttpContextBase>();
HttpContext.Stub(x => x.Request).Return(HttpRequest);
HttpContext.User = _user;
}
示例7: TestInitialize
public void TestInitialize()
{
_context = MockRepository.GenerateMock<HttpContextBase>();
var request = MockRepository.GenerateMock<HttpRequestBase>();
request.Stub(x => x.ApplicationPath).Return("site");
_context.Stub(x => x.Request).Return(request);
}
示例8: SetUp
public void SetUp()
{
_httpRequest = MockRepository.GenerateStub<HttpRequestBase>();
_httpRequest.Stub(r => r.AppRelativeCurrentExecutionFilePath).Return("~/" + URL);
_httpRequest.Stub(r => r.PathInfo).Return("");
_httpRequest.Stub(r => r.Form).Return(_form);
_httpRequest.Stub(r => r.Headers).Return(_headers);
_httpRequest.Stub(r => r.QueryString).Return(_queryString);
_httpContext = MockRepository.GenerateStub<HttpContextBase>();
_httpContext.Stub(c => c.Request).Return(_httpRequest);
var acceptHeaderResponseTypeResolver = MockRepository.GenerateStub<IAcceptHeaderResponseTypeResolver>();
_route = new RestfulRoute(URL, CONTROLLER, new ResponseTypeMapper(acceptHeaderResponseTypeResolver), new ActionMapper());
}
示例9: Setup
public void Setup()
{
_container = new UnityContainer();
_container.RegisterType<UnitySimpleController, UnitySimpleController>();
_container.RegisterType<IDependency, StubDependency>();
_container.RegisterType<UnityDependencyController, UnityDependencyController>();
_mocks = new MockRepository();
_mockContext = _mocks.PartialMock<HttpContextBase>();
_mockContext.Stub(c => c.ApplicationInstance).Return(new MockApplication(_container));
_mocks.ReplayAll();
_context = new RequestContext(_mockContext, new RouteData());
_factory = new UnityControllerFactory();
_factory.InitializeWithControllerTypes(typeof(UnitySimpleController), typeof(UnityDependencyController));
}
示例10: Context
protected override void Context()
{
CustomerService = MockRepository.GenerateStub<ICustomerService>();
Logger = MockRepository.GenerateStub<ILogger>();
_user = new FakePrincipal(new FakeIdentity(Username), null);
HttpRequest = MockRepository.GenerateStub<HttpRequestBase>();
HttpContext = MockRepository.GenerateStub<HttpContextBase>();
HttpContext.Stub(x => x.Request).Return(HttpRequest);
HttpContext.User = _user;
MappingEngine = MockRepository.GenerateStub<IMappingEngine>();
CustomerCreator = MockRepository.GenerateStub<ICustomerCreator>();
CustomerController = new CustomerController(Logger, null, null, null, MappingEngine, CustomerCreator, null);
CustomerController.ControllerContext = new ControllerContext(HttpContext, new RouteData(),
CustomerController);
}
示例11: SetUp
public void SetUp()
{
_session = MockRepository.GenerateStrictMock<HttpSessionStateBase>();
_session.Stub(s => s["Connectionstring"]).Return(Connectionstring);
_context = MockRepository.GenerateStrictMock<HttpContextBase>();
_context.Stub(c => c.Session).Return(_session);
_connectionstringBuilder = MockRepository.GenerateStub<IConnectionstringBuilder>();
_connectionstringBuilder.Expect(cb => cb.BuildConnectionString(Arg<IConnectionstringArguments>.Is.Anything)).Return(Connectionstring);
var sqlServerConnectionstringArgumentsMapper = new SqlServerConnectionstringArgumentsMapper();
_connectionstringArgumentsMapperFactory = MockRepository.GenerateStrictMock<IConnectionstringArgumentsMapperFactory>();
_connectionstringArgumentsMapperFactory.Expect(factory => factory.Make(Arg<string>.Is.Anything)).Return(sqlServerConnectionstringArgumentsMapper);
_schemaReader = MockRepository.GenerateStub<ISchemaReader>();
}
示例12: SetUp
public void SetUp()
{
_httpRequest = MockRepository.GenerateStub<HttpRequestBase>();
_httpRequest.Stub(r => r.PathInfo).Return("");
_httpRequest.Stub(r => r.HttpMethod).Return("Get");
_httpRequest.Stub(r => r.Form).Return(_form);
_httpRequest.Stub(r => r.Headers).Return(_headers);
_httpContext = MockRepository.GenerateStub<HttpContextBase>();
_httpContext.Stub(c => c.Request).Return(_httpRequest);
_routeData = MockRepository.GenerateStub<RouteData>();
_requestContext = MockRepository.GenerateStub<RequestContext>();
_requestContext.RouteData = _routeData;
_requestContext.HttpContext = _httpContext;
_acceptHeaderResponseTypeResolver = MockRepository.GenerateStub<IAcceptHeaderResponseTypeResolver>();
_route = new RestfulRoute(URL, CONTROLLER, new ResponseTypeMapper(_acceptHeaderResponseTypeResolver), new ActionMapper());
}