I am new to MVC / MVP and learn it by building a Winform application.
To some extent, I created models, presenters, and presentations ... Now, where are my tests coming up.
I think that the initial check of the data type (for example, only the numbers in the "Age" field) should be performed on presentation. While other checks (for example, age within 200) should be performed according to the model.
Regarding data type validation, my view provides values as properties
public int? Age { get { int val; if (Int32.TryParse(TbxAge.Text, out val)) { return val; } return null; } set { TbxAge.Text = value; } }
I can perform the test separately, but how can I tell the facilitator that the test has not yet been completed when she tries to access the Age? Resource. In particular, if the field is optional.
Is it good to throw a validationpending exception, but then the leader should catch it at every point.
I understand correctly, or something is missing.
Update (for clarity):. In this simple case, when the age field is optional, what to do when the user entered his name instead of a number. I cannot pass null, as this would mean that the user was left empty by the user. So, how do I inform the presenter that the wrong data is entered ...
c # model-view-controller mvp winforms
The king
source share