static PeopleService() { var ppl = new PeopleBase { FirstName = "Frank", LastName = "Baumgartner", Id = 666 }; ppl.Phones.Add(new PeopleBase.Types.PhoneNumber { Number = "0800 555 666 777", Type = PeopleBase.Types.PhoneType.Mobile }); DefaultCouch = new CoachRes { PeopleBase = ppl, CoachTimeReachableFrom = Timestamp.FromDateTime(DateTime.Now.ToUniversalTime()), CoachTimeReachableTo = Timestamp.FromDateTime(DateTime.Now.AddHours(3).ToUniversalTime()) }; ppl = new PeopleBase { FirstName = "Tim", LastName = "Walter", Id = 42 }; ppl.Phones.Add(new PeopleBase.Types.PhoneNumber { Number = "+49 134 4534234", Type = PeopleBase.Types.PhoneType.Mobile }); DefaultCustomer = new CustomerRes { PeopleBase = ppl }; }
public void ResidentialChargeWithoutUsageTestSucc() { //Arrange decimal usage = 0m; //no usage by customer should still render a charge of $6 CustomerRes customerRes = new CustomerRes(accountNumber, accountName, custType, usage); decimal expectedCharge = 6m; decimal actualCharge; //Act actualCharge = customerRes.CalculateCharge(); //Assert Assert.AreEqual(expectedCharge, actualCharge); }
public void ResidentialChargeWithUsageTestSucc() { //Arrange decimal usage = 100m; CustomerRes customerRes = new CustomerRes(accountNumber, accountName, custType, usage); decimal expectedCharge = 11.2m; decimal actualCharge; //Act actualCharge = customerRes.CalculateCharge(); //Assert Assert.AreEqual(expectedCharge, actualCharge); }
// calculate and display bill to pay private void btnCalculate_Click(object sender, EventArgs e) { // local declaration decimal kWh = 0m; //input: kWh used for residential or commercial customers decimal kWhPeak = 0m; //input: kWh used for industrial customers during peak hours decimal kWhOff = 0m; //input: kWh used for industrial customers during off-peak hours string customer; //input: customer type char custType; //customer type (R, C, or I) // obtain type of customer input from dropbox list customer = cboCustomer.Text; //assign customer type switch (customer) { case "Residential": //focus on the input box txtAccountNo.Focus(); //validate user input for kWh used if (validator.IsProvided(txtAccountNo, "Account Number") && validator.IsNonZeroPositiveInt(txtAccountNo, "Account Number") && validator.IsProvided(txtCustomerName, "Customer Name") && validator.IsString(txtCustomerName, "Customer Name") && validator.IsProvided(txtkWh, "Residential usage") && validator.IsNonNegativeInt(txtkWh, "Residential Usage")) { //assign custType custType = 'R'; //obtain input kWh = Convert.ToDecimal(txtkWh.Text); //create a Customer Object using data from text boxes Customer c = new CustomerRes(Convert.ToInt32(txtAccountNo.Text), txtCustomerName.Text, custType, kWh); //display charge amount in appropriate text box txtBill.Text = c.CalculateCharge().ToString("c"); //add it to the list and display customers.Add(c); //DisplayCustomers(); } break; case "Commercial": //focus on the input box txtAccountNo.Focus(); //validate user input for kWh used if (validator.IsProvided(txtAccountNo, "Account Number") && validator.IsNonZeroPositiveInt(txtAccountNo, "Account Number") && validator.IsProvided(txtCustomerName, "Customer Name") && validator.IsString(txtCustomerName, "Customer Name") && validator.IsProvided(txtkWh, "Commercial usage") && validator.IsNonNegativeInt(txtkWh, "Commercial Usage")) { //assign custType custType = 'C'; //obtain input kWh = Convert.ToDecimal(txtkWh.Text); //create a Customer Object using data from text boxes Customer c = new CustomerComm(Convert.ToInt32(txtAccountNo.Text), txtCustomerName.Text, custType, kWh); //display charge amount in appropriate text box txtBill.Text = c.CalculateCharge().ToString("c"); //add it to the list and display customers.Add(c); //DisplayCustomers(); } break; case "Industrial": //validate user input for kWh used if (validator.IsProvided(txtAccountNo, "Account Number") && validator.IsNonZeroPositiveInt(txtAccountNo, "Account Number") && validator.IsProvided(txtCustomerName, "Customer Name") && validator.IsString(txtCustomerName, "Customer Name") && validator.IsProvided(txtkWhPeak, "Industrial peak hours usage") && validator.IsNonNegativeInt(txtkWhPeak, "Industrial peak hours usage") && validator.IsProvided(txtkWhOff, "Industrial off-peak hours usage") && validator.IsNonNegativeInt(txtkWhOff, "Industrial off-peak hours usage")) { //assign custType custType = 'I'; //obtain input(s) kWhPeak = Convert.ToDecimal(txtkWhPeak.Text); kWhOff = Convert.ToDecimal(txtkWhOff.Text); //create a Customer Object using data from text boxes Customer c = new CustomerInd(Convert.ToInt32(txtAccountNo.Text), txtCustomerName.Text, custType, kWhPeak, kWhOff); //display charge amount in appropriate text box txtBill.Text = c.CalculateCharge().ToString("c"); //add it to the list and display customers.Add(c); } break; default: break; } }