private void IndusResp(IndusCustomer args, int userUsage, int offUsage) { //Populates the form with extra details and the total bill. txtFlatRate.Text = FIXEDINDUSPEAK.ToString("c"); txtFlatRateLimit.Text = LIMITINDUSPEAK.ToString("n"); txtUsageRate.Text = RATEINDUSPEAK.ToString("c4"); //Checks to see if the customer has used more than their metered limit for peak hours. Same algorithm/logic as commerical case. if ((userUsage - LIMITINDUSPEAK) > 0) { txtOverLimit.Text = (userUsage - LIMITINDUSPEAK).ToString("n"); } else { txtOverLimit.Text = "N/A"; txtUsageCost.Text = "N/A"; } txtFlatRateOff.Text = FIXEDINDUSOFF.ToString("c"); txtFlatRateLimitOff.Text = LIMITINDUSOFF.ToString("n"); txtUsageRateOff.Text = RATEINDUSOFF.ToString("c4"); //Repeats the above method for the off-peak hours. if ((offUsage - LIMITINDUSOFF) > 0) { txtOverLimitOff.Text = (offUsage - LIMITINDUSOFF).ToString("n"); } else { txtOverLimitOff.Text = "N/A"; txtUsageCostOff.Text = "N/A"; } //Use the calculateCharge method and ToString method to return metered cost. args.CalculateCharge(); txtTotalCost.Text = args.ToString(); //Shows the user their total bill. //Write customer data to a local .txt file. String cusData = $"{args.CusName}|{args.AccNo}|{args.CusType}|{args.ToString()}"; ReadWrite.recordCustomer(cusData); /*Adds the new customer's data to the dataGridView. * Makes it so that the dataGridView does not need to be reinitialized every time.*/ addToDataGrid(args.CusName, args.AccNo, args.CusType, args.ToString()); //Adds the new customer to the list of Customer objects being accessed by the form. currentCus.Add(args); }
//Method to test if industiral customer class calculates properly on a peak usage of 2000 kWh and an off-peak usage of 2000 kWh. public void IndusCustomerWith2000And2000() { //Arrange //Set up all parameters to initalize a new industrial customer. String name = "Test"; int accNo = 0; char cusType = 'I'; int usage = 2000; int offUsage = 2000; IndusCustomer testCustomer = new IndusCustomer(name, accNo, cusType, usage, offUsage); string expectedCharge = "$209.00"; //Expected return value for CalculateCharge //Act testCustomer.CalculateCharge(); //Assert string actualCharge = testCustomer.ToString(); Assert.AreEqual(expectedCharge, actualCharge); }