本文整理汇总了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;
}
示例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 </td></tr>"));
}
示例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));
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例8: SetUp
public void SetUp()
{
_mocks = new MockRepository();
_controllerContext = new ControllerContext(_mocks.DynamicHttpContextBase(), new RouteData(), _mocks.DynamicMock<ControllerBase>());
_mocks.ReplayAll();
}
示例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();
}
示例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>"));
}
示例11: Initialize
public void Initialize()
{
_mocks = new MockRepository();
_context = _mocks.DynamicHttpContextBase();
_mocks.ReplayAll();
}