kala-tamin asp.net mvc rhino mocks mocking httprequest values
صفحه اصلي

asp.net mvc rhino mocks mocking httprequest values

Hello there Im trying to write a test can I mock a HttpRequestBase to return post values like this? please help as its quite urgent, how can I acheive this?

var collection = new NameValueCollection(); collection.Add("Id", "1"); collection.Add("UserName", "");   var mocks = new MockRepository();    using (mocks.Record())   {       Expect.Call(requestBase.Params).Return(collection);   } 

Basically I have a requirement that rquires me to mock request post parameters as opposed to form values as the UI client is not a html form, any ideas how to fake/mock the httprequest post params? the return type is a nameVaueCollection

New suggestions for error handling in ASP.NET MVC 2


ASP.NET WebForms with MVC localization issue
You're not going to like hearing this, although you're going around this the wrong way. Is it possible to map complex types with SolrNet You should be using models for your inputs and letting the model binder fill in the properties rather than receive ting the values out of the request parameters directly. Resolve Array with Ninject This will make your life, including mocking enough easier, since you'll be supplying a model as a parameter to the action method rather than having to mock up the HttpRequest object.. How to use AJAX Post to invoke ASP.NET MVC Controller action and return new View?
var model = new UserModel { ID = 1, UserName = string.Empty };  var controller = new FooController();  var result = controller.FooAction( model ); 
If you need use the parameters, then at least I suggest you use the AAA syntax for your mocks.. using different site.master files for themes
var request = MockRepository.GenerateMock<HttpRequestBase>(); var context = MockRepository.GenerateMock<HttpContextBase>();  var collection = new NameValueCollection();    collection.Add("Id", "1");    collection.Add("UserName", "");  context.Expect( c => c.Request ).Return( request ).Repeat.Any(); request.Expect( r => r.Params ).Return( collection ).Repeat.Any()  var controller = new FooController(); controller.ControllerContext = new ControllerContext( context, new RouteData(), controller );  var result = controller.FooAction();  ... How to display Images using HtmlHelper Class- ASP.NET MVC context.VerifyAllExpectations(); request.VerifyAllExpectations(); 
asp.net mvc 2 custom service account

53 out of 100 based on 33 user ratings 233 reviews