//If a customer is commercial, use the specified commercial rates. private void CommResp(CommCustomer args, int userUsage) { //Populates the form with extra details and the total bill. txtFlatRate.Text = FIXEDCOMM.ToString("c"); txtFlatRateLimit.Text = LIMITCOMM.ToString("n"); txtUsageRate.Text = RATECOMM.ToString("c4"); if ((userUsage - LIMITCOMM) > 0) { txtOverLimit.Text = (userUsage - LIMITCOMM).ToString("n"); } else { txtOverLimit.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); }
public void CommCustomerWith1000() { //Arrange //Set up all parameters to initalize a new commercial customer. String name = "Test"; int accNo = 0; char cusType = 'C'; int usage = 1000; CommCustomer testCustomer = new CommCustomer(name, accNo, cusType, usage); string expectedCharge = "$60.00"; //Expected return value for CalculateCharge //Act testCustomer.CalculateCharge(); //Assert string actualCharge = testCustomer.ToString(); Assert.AreEqual(expectedCharge, actualCharge); }