rhino-mocks

Mocking Static methods using Rhino.Mocks

萝らか妹 提交于 2019-11-26 09:44:04
问题 Is it possible to mock a static method using Rhino.Mocks? If Rhino does not support this, is there a pattern or something which would let me accomplish the same? 回答1: Is it possible to mock a static method using Rhino.Mocks No, it is not possible. TypeMock can do this because it utilizes the CLR profiler to intercept and redirect calls. RhinoMocks, NMock, and Moq cannot do this because these libraries are simpler; they don't use the CLR profiler APIs. They are simpler in that they use proxies

What are the differences between mocks and stubs on Rhino Mocks?

风格不统一 提交于 2019-11-26 04:59:57
问题 I haven\'t play enough with this and usually use mocks, but I wonder what are the differences between this two and when to use one or the other on Rhino Mocks. Update: I also found the answer to my question in Ayende\'s words: The difference between stubs and mocks You can get the actual definition of the these terms in this article: Mocks Aren\'t Stubs. I want to focus on the difference from the point of view of Rhino Mocks. A mock is an object that we can set expectations on, and which will

Mocking Asp.net-mvc Controller Context

雨燕双飞 提交于 2019-11-26 04:09:43
问题 So the controller context depends on some asp.net internals. What are some ways to cleanly mock these up for unit tests? Seems like its very easy to clog up tests with tons of setup when I only need, for example, Request.HttpMethod to return \"GET\". I\'ve seen some examples/helpers out on the nets, but some are dated. Figured this would be a good place to keep the latest and greatest. I\'m using latest version of rhino mocks 回答1: Using MoQ it looks something like this: var request = new Mock

How to mock the Request on Controller in ASP.Net MVC?

∥☆過路亽.° 提交于 2019-11-26 03:37:01
问题 I have a controller in C# using the ASP.Net MVC framework public class HomeController:Controller{ public ActionResult Index() { if (Request.IsAjaxRequest()) { //do some ajaxy stuff } return View(\"Index\"); } } I got some tips on mocking and was hoping to test the code with the following and RhinoMocks var mocks = new MockRepository(); var mockedhttpContext = mocks.DynamicMock<HttpContextBase>(); var mockedHttpRequest = mocks.DynamicMock<HttpRequestBase>(); SetupResult.For(mockedhttpContext