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


C# MockRepository.DynamicHttpContextBase方法代码示例

本文整理汇总了C#中Rhino.Mocks.MockRepository.DynamicHttpContextBase方法的典型用法代码示例。如果您正苦于以下问题:C# MockRepository.DynamicHttpContextBase方法的具体用法?C# MockRepository.DynamicHttpContextBase怎么用?C# MockRepository.DynamicHttpContextBase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rhino.Mocks.MockRepository的用法示例。


在下文中一共展示了MockRepository.DynamicHttpContextBase方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DynamicHttpContextBase

 public static HttpContextBase DynamicHttpContextBase()
 {
     var mocks = new MockRepository();
     var context = mocks.DynamicHttpContextBase();
     mocks.ReplayAll();
     return context;
 }
开发者ID:pedroreys,项目名称:BlogPosts,代码行数:7,代码来源:MvcMockHelpers.cs

示例2: Handler_should_match_route

        public void Handler_should_match_route()
        {
            var handler = new DebugHttpHandler();
            var mocks = new MockRepository();
            var context = mocks.DynamicHttpContextBase();

            SetupResult.For(context.Request.AppRelativeCurrentExecutionFilePath).Return("~/Home/");
            SetupResult.For(context.Request.PathInfo).Return("Index");

            var routes = new RouteCollection
                             {
                                 new Route("{controller}/{action}/{id}", null, new MvcRouteHandler()),
                                 new Route("{controller}/{action}", null, new MvcRouteHandler()),
                                 new Route("{controller}/{action}", new RouteValueDictionary(new Hash(Controller => "Home")),
                                           new MvcRouteHandler())
                             };
            RouteDebugger.RewriteRoutesForTesting(routes);

            mocks.ReplayAll();
            var routeData = new RouteData(routes[0], new DebugRouteHandler());
            routeData.Values.Add("Controller", "Home");
            routeData.Values.Add("Action", "Index");

            handler.RequestContext = new RequestContext(context, routeData);
            handler.ProcessRequest(context, routes);

            Assert.That(context.Response.Output.ToString().Contains("<tr><td>Controller</td><td>Home&nbsp;</td></tr>"));
        }
开发者ID:EagleFlyHigh,项目名称:MvcContrib,代码行数:28,代码来源:RouteDebuggerTester.cs

示例3: DebugRouteHandler_should_create_DebugHttpHandler

        public void DebugRouteHandler_should_create_DebugHttpHandler()
        {
            var mocks = new MockRepository();
            var handler = new DebugRouteHandler();
            var context = new RequestContext(mocks.DynamicHttpContextBase(), new RouteData());

            var httpHandler = handler.GetHttpHandler(context);
            Assert.That(httpHandler, Is.InstanceOf<DebugHttpHandler>());
            Assert.That(((DebugHttpHandler)httpHandler).RequestContext, Is.SameAs(context));
        }
开发者ID:EagleFlyHigh,项目名称:MvcContrib,代码行数:10,代码来源:RouteDebuggerTester.cs

示例4: ControllerSetsViewEngine

        public void ControllerSetsViewEngine()
        {
            MockRepository mocks = new MockRepository();
            RequestContext context = new RequestContext(mocks.DynamicHttpContextBase(), new RouteData());

            SparkControllerFactory controllerFactory = new SparkControllerFactory();
            MvcContrib.ConventionController controller =
                (MvcContrib.ConventionController)((IControllerFactory)controllerFactory).CreateController(context, "Convention");

            Assert.IsNotNull(controller.ViewEngine);
            Assert.IsAssignableFrom(typeof(SparkViewFactory), controller.ViewEngine);
        }
开发者ID:Eilon,项目名称:spark,代码行数:12,代码来源:SparkControllerFactoryTester.cs

示例5: Setup

        public void Setup()
        {
            _container = new WindsorContainer();
            _factory = new WindsorControllerFactory(_container);

            _container.AddComponent("simplecontroller", typeof(WindsorSimpleController));
            _container.AddComponent("StubDependency", typeof(IDependency), typeof(StubDependency));
            _container.AddComponent("dependencycontroller", typeof(WindsorDependencyController));

            _factory.InitializeWithControllerTypes(typeof(WindsorSimpleController), typeof(WindsorDependencyController));

            var mocks = new MockRepository();
            _context = new RequestContext(mocks.DynamicHttpContextBase(), new RouteData());
            mocks.ReplayAll();
        }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:15,代码来源:WindsorControllerFactoryTester.cs

示例6: Setup

		public void Setup()
		{
			_mocks = new MockRepository();
			_context = _mocks.DynamicHttpContextBase();
			SetupResult.For(_context.Request.FilePath).Return("Test.mvc");
		    var view = _mocks.DynamicMock<IView>();
			_viewContext = new ViewContext(new ControllerContext(_context, new RouteData(), _mocks.DynamicMock<ControllerBase>()), view, new ViewDataDictionary(), new TempDataDictionary());
			_helper = new HtmlHelper(_viewContext, new ViewPage());
			_people = new List<Person>
			              	{
			              		new Person { Id = 1, Name = "Jeremy", DateOfBirth = new DateTime(1987, 4, 19)}
			              	};
			AddToViewData("people", _people);
			_mocks.ReplayAll();

		}
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:16,代码来源:HtmlGridTester.cs

示例7: SetUp

        public virtual void SetUp()
        {
            HttpMethodToReturn = "GET";
            EcmaScriptVersionToReturn = new Version(1, 1);

            mockRepository = new MockRepository();
            HttpContext = mockRepository.DynamicHttpContextBase();
            SetupResult.For(Request.UserHostAddress).Return("::1");
            SetupResult.For(Request.UserHostName).Return("::1");
            SetupResult.For(Request.RequestType).Do(new Func<string>(() => HttpMethodToReturn)); //.Return("GET");
            SetupResult.For(Request.HttpMethod).Do(new Func<string>(() => HttpMethodToReturn));
            SetupResult.For(Request.PhysicalApplicationPath).Return("http://testing/mycontroller/test");
            SetupResult.For(Request.Url).Return(new Uri("http://testing/mycontroller/test"));
            mockRepository.Replay(Request);
            SetupResult.For(Request.Browser.EcmaScriptVersion).Do(new Func<Version>(() => EcmaScriptVersionToReturn));
            SetupResult.For(Request.Browser.Browser).Return("Firefox 2.0.11");
            SetupResult.For(HttpContext.User.Identity).Return(new MockIdentity {Name = string.Empty});
            mockRepository.ReplayAll();
        }
开发者ID:mvccontrib,项目名称:XsltViewEngine,代码行数:19,代码来源:ViewTestBase.cs

示例8: SetUp

 public void SetUp()
 {
     _mocks = new MockRepository();
     _controllerContext = new ControllerContext(_mocks.DynamicHttpContextBase(), new RouteData(), _mocks.DynamicMock<ControllerBase>());
     _mocks.ReplayAll();
 }
开发者ID:kouweizhong,项目名称:MvcContrib,代码行数:6,代码来源:XmlActionResultTester.cs

示例9: SetupHtmlHelper

        private void SetupHtmlHelper(object model , Dictionary<string,object> viewData)
        {
            _mocks = new MockRepository();
            _context = _mocks.DynamicHttpContextBase();
            SetupResult.For(_context.Request.FilePath).Return("Test.mvc");
            var view = _mocks.DynamicMock<IView>();
            _viewContext = new ViewContext(new ControllerContext(_context, new RouteData(), _mocks.DynamicMock<ControllerBase>()), view, new ViewDataDictionary(), new TempDataDictionary(), new StringWriter());
            _helper = new HtmlHelper(_viewContext, new ViewPage());

            if (model != null)
            {
                _viewContext.ViewData.Model = model;
            }
            if (viewData!=null)
            {
                foreach(string key in viewData.Keys)
                {
                    _viewContext.ViewData.Add(key, viewData[key]);
                }

            }

            _mocks.ReplayAll();
        }
开发者ID:joaofx,项目名称:mvccontrib,代码行数:24,代码来源:ModelVisualizerTester.cs

示例10: Handler_should_not_match_route

        public void Handler_should_not_match_route()
        {
            var handler = new DebugHttpHandler();
            var mocks = new MockRepository();
            var context = mocks.DynamicHttpContextBase();

            SetupResult.For(context.Request.AppRelativeCurrentExecutionFilePath).Return("~/");
            SetupResult.For(context.Request.PathInfo).Return(string.Empty);

            var routes = new RouteCollection();
            RouteDebugger.RewriteRoutesForTesting(routes);

            mocks.ReplayAll();

            var routeData = new RouteData(DebugRoute.Singleton, new DebugRouteHandler());

            handler.RequestContext = new RequestContext(context, routeData);
            handler.ProcessRequest(context, routes);

            Assert.That(context.Response.Output.ToString().Contains("<strong class=\"false\">NO MATCH!</strong>"));
        }
开发者ID:EagleFlyHigh,项目名称:MvcContrib,代码行数:21,代码来源:RouteDebuggerTester.cs

示例11: Initialize

 public void Initialize()
 {
     _mocks = new MockRepository();
     _context = _mocks.DynamicHttpContextBase();
     _mocks.ReplayAll();
 }
开发者ID:EagleFlyHigh,项目名称:MvcContrib,代码行数:6,代码来源:HttpContextExtensionsTester.cs


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