![]() ![]() Okay, so how do I mock RedirectToAction when it isn't public? I thought all of these actionable methods were going to be public to avoid the subclass testing patterny thingo - which involved alot of duplicated code. I'm not exactly sure what's going on here, but I bet it has something to do with redirects trying to call a 301 on some part of System.Web that wasn't mocked. StackTrace: at (String url) at HttpResponseBaseProxy2ad1c711cecc4e6da524bc5c50bdce13.Redirect_callback_20(String url) at HttpResponseBaseProxy2ad1c711cecc4e6da524bc5c50bdce13.InvocationRedirect_32.InvokeMethodOnTarget() at () at .DoMethodCall(IInvocation invocation, MethodInfo method, Object args) at .MethodCall(IInvocation invocation, MethodInfo method, Object args) at (IInvocation invocation, Object proxy, MethodInfo method, Object args) at .Intercept(IInvocation invocation) at () at HttpResponseBaseProxy2ad1c711cecc4e6da524bc5c50bdce13.Redirect(String url) at .RedirectToAction(RouteValueDictionary values) at .RedirectToAction(String actionName) at CN.(Int32 id) in C:\Projects\CharlesNicholas\CN.Web\Controllers\ReminderMessagesController.cs:line 78 at CN.() in C:\Projects\CharlesNicholas\CN.Web.Test\ReminderMessagesControllerTests.cs:line 141 ![]() Message:The method or operation is not implemented. RhinoMocks works in a record/playback way, that is by default it’s in record mode so if in TestDynamic we comment out repository.ReplayAll () we’ll get the exception InvalidOperationException. } with the MbUnit test execution exception: Now to return to repository.ReplayAll (). I'm looking for a tutorial which does not have any assumed prior Rhino Mocks knowledge. However, the links on the suggested page do not work (it simply takes me back to the blog homepage). But, my normal operation unit test fails, I realise that there exist some posts such as this one which have asked the same question. ![]() Its purpose is to ease testing by allowing the developer to create mock implementations of custom objects and verify the interactions using unit testing. Here's one of my controller actions that uses RedirectToAction:Ĥ throw new ArgumentException( "Message cannot be null or empty") ĩ 10 11 12 db.ReminderMessages.InsertOnSubmit(rm) įor the ReminderMessagesController My error unit tests run fine, cos they're exception expecting. There is a newer version of this package available. However, my controller tests fail :( Reliably, it's the controller tests that are asserting that RedirectToAction was called.Ĭos preview 2 supports controller mocking, I ditched the sub-class testing patterny thing and opted for the mocking. I wrote alot of code using the first preview, so it's taken me an hour or two to completely upgrade. (2) Remove old references to Rhino Mocks 3.5 and add references to this newly downloaded library.I just upgraded my little playground web app to Preview 2. This contains Castle libraries Externally and not embedded like without Castle assemblies version. Until these interfaces are made internal, here is a Solution, that can help you solve the problem: NET.Īnyways, to cut the story short, Rhino Mocks 3.5 also uses Castle framework to generate proxies for Strict Mocks, Partial Mocks etc… We used the Rhino Mock 3.5 (with Castle internalized version) and it exposes the some of the Castle.Core interfaces publicly, for example, like the IInvocation and this caused Ambiguous Reference when the tests refer to Castle and Rhino Mocks. We are not using other Castle Components, instead we use NHibernate directly and use Spring. We chose to use Castle framework (known for its excellent Dynamic Proxy Support, even NHibernate internally uses Castle). To implement the AccessLog functionality, we needed to create Dynamic Proxy and intercept calls. NET, we are using Rhino Mock 3.5 as the Mocking framework.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |