The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Model View presenter

Hi,
I am working on to understand concept of model view presenter,in asp.net context.I have a login webpage with 2 textboxes-Loginname and password,and a button (save).
There is an interface ILoginView with properties-LoginName and LoginPassword(only get).Also,there is a presenter class with constructor which takes ILoginView type.Also,presenter has a  save method,called on save click from aspx page.In this save method ,I create a login object and initialize it with values using ILoginView type object.Now,do I need to test the save method on Presenter.If so,how do I test it?
What I understand is the test should be that presenter gets the values it needs from View.Or am I on wrong path?
neo
Monday, July 30, 2007
 
 
I typically create the presenter earlier in the page life cycle rather than on demand like you're doing.

The simplest way to test the presenter is to create a mock view and pass it to your presenter, that way you can test how it interacts with the view.

A good article on an asp.net flavored MVP is here http://haacked.com/archive/2006/08/09/ASP.NETSupervisingControllerModelViewPresenterFromSchematicToUnitTestsToCode.aspx

Hope this helps
Nigel Sampson Send private email
Monday, July 30, 2007
 
 
Hi,
I am creating a mock,and using it to test.But,how to test in my given scenario?
neo
Monday, July 30, 2007
 
 
Using a mock view you can test that when you call Save (although shouldn't this be a different name on a login page?) on the presenter that it retrieves the values from the view.

If you've mocked the data store the presenter uses then you can test that the presenter asks the data store for the user details relating the the user your mock view gave the presenter.

If your view has some feedback fields "Login failed" etc your mocked data store can pass back both valid and invalid users and you can test the presenter sets the appropriate feedback in the view.

In MVP the presenter is pretty much a broker of messages and events. Therefore the testing you do on it is mostly interaction rather than state based.

Hope this helps
Nigel Sampson Send private email
Monday, July 30, 2007
 
 
>> how to test in my given scenario? <<

Just call the methods with known data & see what you get back.
xampl Send private email
Monday, July 30, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz