MVP Pattern and Session Values
asp.net, mvp
Solution
The Presenter should not be aware of the Session object (or anything else from System.Web), but it can be aware of the values if you expose the session data via your view.
With MVP you have a view like this:
public interface IViewCustomerView
{
ShoppingCartModel ShoppingCart {get;set}
}
In your web form implementation of the view, ShoppingCart comes from the session.
public partial class ViewCustomers : Page, IViewCustomerView
ShoppingCartModel ShoppingCart
{
// add null/cast checks etc. here
get { return (ShoppingCartModel) Session["Cart"]; }
set { Session["Cart"] = value; }
}
In your web forms and mock implementations it can come from somewhere else. Then in the presenter, when you access the shopping cart, it has no idea that it came from the session:
IViewCustomerView _view;
_view.ShoppingCart...
Problem
I have a question regarding the ASP.NET MVP Pattern. Can a Presenter be aware of the session values? If I start using sessions values I have no idea how to mock or test that for session and also what if I use the same presenter for a Win form. Is this a right thaught and if so what are my options on dealing with session values.