Application is using MVP - passive view pattern and we learned that all events in the aspx.cs needs to call the presenter methods instead of directly accessing the model.
We are using gridview to display the data and one of the column color must change based on the flag and some text needs to be appended. However, we are not sure how we can move below piece of code to presenter to be able to write unit tests.
protected void dqGrid_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
var creditOrDebit = ((Label)e.Row.FindControl("lblCreditOrDebit")).Text;
if(creditOrDebit == "Debit")
{
Label lblAmount = ((Label)e.Row.FindControl("lblAmount"));
lblAmount.CssClass = "txtRed";
lblAmount.Text = "-" + lblAmount.Text;
}
}
}
Edit:
We thought of having a function in the presenter that takes amount as input and returns back css but as a guideline we see that all methods in presenter needs to be void since it already has View property.