public void CalculateTotalValue_TwoRowsWithTheThirdCellUseful_ShouldCalculateTheResult() { //prepares mock data string[,] mockRowValues = new string[, ] { { "", "", "99.99" }, { "", "", "299.99" } }; var mockRows = new ArrayList(); GridViewRowCollection mockRowCollection; for (int i = 0; i < mockRowValues.GetLength(0); i++) { //instantiates grid view rows GridViewRow tempRow = new GridViewRow(i, i, DataControlRowType.DataRow, DataControlRowState.Normal); for (int j = 0; j < mockRowValues.GetLength(1); j++) { //instantiates cells, populates them and puts them in current row TableCell tempCell = new TableCell(); tempCell.Text = mockRowValues[i, j]; tempRow.Cells.Add(tempCell); } //adds current row in a mock row collection mockRows.Add(tempRow); } mockRowCollection = new GridViewRowCollection(mockRows); //tests against assertion string totalValueLiteral = ReportHelper.CalculateTotalValue(mockRowCollection, 2); Assert.AreEqual(totalValueLiteral, "399.98"); }
public void CalculateTotalValue_EmptyRow_ShouldReturnZero() { //prepares mock data GridViewRowCollection mockRowCollection; var mockRows = new ArrayList(); mockRowCollection = new GridViewRowCollection(mockRows); //tests against assertion string totalValueLiteral = ReportHelper.CalculateTotalValue(mockRowCollection, 2); Assert.AreEqual(totalValueLiteral, "0"); }
protected void ValueInTransitView_DataBound(object sender, EventArgs e) { int lastColumn = ValueInTransitView.Columns.Count - 1; TotalValueLiteral.Text = ReportHelper.CalculateTotalValue(ValueInTransitView.Rows, lastColumn); }
protected void GlobalStockView_DataBound(object sender, EventArgs e) { int lastColumn = GlobalStockView.Columns.Count - 1; TotalValueLiteral.Text = ReportHelper.CalculateTotalValue(GlobalStockView.Rows, lastColumn); }
protected void DoctorActivityView_DataBound(object sender, EventArgs e) { int lastColumn = DoctorActivityView.Columns.Count - 1; TotalValueLiteral.Text = ReportHelper.CalculateTotalValue(DoctorActivityView.Rows, lastColumn); }
/// <summary> /// On data bound event of the distribution centre stock view, /// calculates total of each entry's value /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DistributionCentreStockView_DataBound(object sender, EventArgs e) { int lastColumn = DistributionCentreStockView.Columns.Count - 1; TotalValueLiteral.Text = ReportHelper.CalculateTotalValue(DistributionCentreStockView.Rows, lastColumn); }