In my Asp.net MVC application, I have two methods on the controller: one when the user first arrives at the view, and then one when they submit the form on the specified view.
public ActionResult Foo() {} [AcceptVerbs(HttpVerbs.Post)] public ActionResult Foo(string id, Account accountToFoo) {}
In the second step, there is a custom mediator that collects the account object on which I operate, although this is really not important. All this works fine when testing locally on the server.
We try to be very good at writing unit tests to verify that all of our different views are routed correctly, including those that are HTTP POST. For this, we used the mvccontrib test helper.
Testing is super easy
"~/account/foo/myusername". Route(). ShouldMapTo<AccountController>(c => c.Foo("myusername"));
My question is testing POST routes, how do I write a lambda that I will use to verify that the message is receiving exact values ββsimilar to the above GET test?
For POST, it looks something like this:
"~/account/foo". WithMethod(HttpVerbs.Post). ShouldMapTo<AccountController>(a => something_something);
This is part of my lambda that I'm having problems with. Using arbitrary values ββdoes not work ("a => a.Foo (0, new account ()"). How can I specify the expected values ββas part of the test?
EDIT I was hoping there was something similar to how Moq has lambdas for statements like foo.Setup (s => s.Foo (It.IsAny (), It.Is (i => i> 32 )), etc. Even I have to explicitly specify values ββthat are workable - I just can not imagine the desired structure for the transfer of these explicit values.
bakasan
source share