当前位置: 首页>>代码示例>>C#>>正文


C# HttpContextBase.Stub方法代码示例

本文整理汇总了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);
        }
开发者ID:AcklenAvenue,项目名称:PRTools,代码行数:25,代码来源:given_an_account_controller_context.cs

示例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);
        }
开发者ID:rhwy,项目名称:SampArch,代码行数:13,代码来源:HttpContextMock.cs

示例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);
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:13,代码来源:AspNetServiceArgumentsTester.cs

示例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);
        }
开发者ID:bclubb,项目名称:yabe,代码行数:15,代码来源:WebSpecification.cs

示例5: SetUp

        public void SetUp()
        {
            theHttpContext = MockRepository.GenerateMock<HttpContextBase>();
            theHttpSession = new StubSession();
            theHttpContext.Stub(x => x.Session).Return(theHttpSession);

            theSessionState = new SimpleSessionState(theHttpContext);
        }
开发者ID:cothienlac86,项目名称:fubumvc,代码行数:8,代码来源:SimpleSessionStateTester.cs

示例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;
 }
开发者ID:AcklenAvenue,项目名称:PRTools,代码行数:8,代码来源:given_a_httpcontext_context.cs

示例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);
        }
开发者ID:Mike343,项目名称:Netcoders,代码行数:10,代码来源:PathExtensionTest.cs

示例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());
        }
开发者ID:bnathyuw,项目名称:Restful-Simple-MVC,代码行数:15,代码来源:GetRouteDataActionTests.cs

示例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));
        }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:16,代码来源:UnityControllerFactoryTester.cs

示例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);
        }
开发者ID:AcklenAvenue,项目名称:PRTools,代码行数:18,代码来源:given_a_customer_controller_context.cs

示例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>();
        }
开发者ID:gigapr,项目名称:DatabaseExplorer,代码行数:17,代码来源:DatabaseExplorerControllerTest.cs

示例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());
        }
开发者ID:bnathyuw,项目名称:Restful-Simple-MVC,代码行数:20,代码来源:GetVirtualPathResponseTypeTests.cs


注:本文中的System.Web.HttpContextBase.Stub方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。