public void AddMethodOk() { //instance of class var allPolicies = new clsPolicyCollection(); //create an item of test data var testItem = new clsPolicy(); //store the PK var primaryKey = 0; //set the properties testItem.Accepted = true; testItem.CustomerId = 111; testItem.PolicyDetails = "Lorem ipsum dolor sit amet,"; testItem.PolicyId = 112; testItem.Price = 64.00M; testItem.StaffId = 68; testItem.StartDate = DateTime.Now.Date; //set the ThisPolicy to test data allPolicies.ThisPolicy = testItem; //add record primaryKey = allPolicies.Add(); //set the PK of the test data testItem.PolicyId = primaryKey; //find the record allPolicies.ThisPolicy.Find(primaryKey); //test to see if the 2 values are the same Assert.AreEqual(allPolicies.ThisPolicy, testItem); }
public void ReportByCustomerIdDataFound() { var filteredPolicies = new clsPolicyCollection(); var OK = true; filteredPolicies.ReportByCustomerId("26"); if (filteredPolicies.Count == 3) { if (filteredPolicies.PolicyList[0].PolicyId != 14) { OK = false; } if (filteredPolicies.PolicyList[1].PolicyId != 23) { OK = false; } if (filteredPolicies.PolicyList[2].PolicyId != 36) { OK = false; } } else { OK = false; } Assert.IsTrue(OK); }
public void DeleteMethodOk() { //instance of class var allPolicies = new clsPolicyCollection(); //create an item of test data var testItem = new clsPolicy(); //store the PK var primaryKey = 0; //set the properties testItem.Accepted = true; testItem.CustomerId = 111; testItem.PolicyDetails = "Lorem ipsum dolor sit amet,"; testItem.PolicyId = 112; testItem.Price = 64.00M; testItem.StaffId = 68; testItem.StartDate = DateTime.Now.Date; //set the ThisPolicy to test data allPolicies.ThisPolicy = testItem; //add record primaryKey = allPolicies.Add(); //set the PK of the test data testItem.PolicyId = primaryKey; //find the record allPolicies.ThisPolicy.Find(primaryKey); //delete the record allPolicies.Delete(); var found = allPolicies.ThisPolicy.Find(primaryKey); //test to see that the record was not found Assert.IsFalse(found); }
public void InstanceOk() { //create an instance of the class to test var allPolicies = new clsPolicyCollection(); //test to see if exists Assert.IsNotNull(allPolicies); }
protected void btnApply_Click(object sender, EventArgs e) { var Policies = new clsPolicyCollection(); Policies.ReportByCustomerId(txtCustomerId.Text); lstPolicyList.DataSource = Policies.PolicyList; lstPolicyList.DataValueField = "PolicyId"; lstPolicyList.DataTextField = "CustomerId"; lstPolicyList.DataBind(); }
public void ReportByCustomerIdNoneFound() { //filtered data instance var filteredPolicies = new clsPolicyCollection(); //apply blank string (all records) filteredPolicies.ReportByCustomerId("000"); //test to see that there are no record Assert.AreEqual(0, filteredPolicies.Count); }
protected void btnOK_Click(object sender, EventArgs e) { var aPolicy = new clsPolicy(); aPolicy.PolicyId = int.Parse(txtPolicyId.Text); var staffId = txtStaffId.Text; var customerId = txtCustomerId.Text; var price = txtPrice.Text; var policeDetails = txtPolicyDetails.Text; var startDate = calStartDate.SelectedDate.ToString(); var error = aPolicy.Valid(staffId, customerId, policeDetails, startDate, price); if (error == "") { //capture policy id aPolicy.PolicyId = PolicyId; aPolicy.StaffId = int.Parse(txtStaffId.Text); aPolicy.CustomerId = int.Parse(txtCustomerId.Text); aPolicy.Price = decimal.Parse(Convert.ToDecimal(txtPrice.Text).ToString("N2")); aPolicy.StartDate = calStartDate.SelectedDate; aPolicy.PolicyDetails = txtPolicyDetails.Text; aPolicy.Accepted = Convert.ToBoolean(chkAccepted.Checked); // Session["APolicy"] = aPolicy; //create a new instance of the policy collection var policyList = new clsPolicyCollection(); //if this is a new record if (PolicyId == -1) { //set the ThisPolicy property policyList.ThisPolicy = aPolicy; //add new record policyList.Add(); } //otherwise it must be an update else { //find record policyList.ThisPolicy.Find(PolicyId); //set the ThisPolicy property policyList.ThisPolicy = aPolicy; //update the record policyList.Update(); } //redirect back to listpage Response.Redirect("PolicyList.aspx"); // Response.Redirect("PolicyViewer.aspx"); } else { lblError.Text = error; } }
protected void btnYes_Click(object sender, EventArgs e) { //instance of policy var PolicyList = new clsPolicyCollection(); //find the record PolicyList.ThisPolicy.Find(PolicyId); //delete the record PolicyList.Delete(); //redirect back to main Response.Redirect("PolicyList.aspx"); }
public void ReportByCustomerIdOk() { //instance of class var allPolicies = new clsPolicyCollection(); //filtered data instance var filteredPolicies = new clsPolicyCollection(); //apply blank string (all records) filteredPolicies.ReportByCustomerId(""); //test if same Assert.AreEqual(allPolicies.Count, filteredPolicies.Count); }
private void DisplayPolicy() { //instance of address book var policyList = new clsPolicyCollection(); //find record policyList.ThisPolicy.Find(PolicyId); //display data for this record txtPolicyId.Text = policyList.ThisPolicy.PolicyId.ToString(); txtStaffId.Text = policyList.ThisPolicy.StaffId.ToString(); txtCustomerId.Text = policyList.ThisPolicy.CustomerId.ToString(); txtPolicyDetails.Text = policyList.ThisPolicy.PolicyDetails; txtPrice.Text = policyList.ThisPolicy.Price.ToString(); chkAccepted.Checked = policyList.ThisPolicy.Accepted; calStartDate.VisibleDate = policyList.ThisPolicy.StartDate; calStartDate.SelectedDate = policyList.ThisPolicy.StartDate; }
public void ThisPolicyPropertyOk() { //instance of class var allPolicies = new clsPolicyCollection(); //test data var testPolicy = new clsPolicy(); //set properties of test item testPolicy.Accepted = true; testPolicy.CustomerId = 11; testPolicy.PolicyDetails = "Lorem ipsum dolor sit amet,"; testPolicy.PolicyId = 2; testPolicy.Price = 64.00M; testPolicy.StaffId = 68; testPolicy.StartDate = DateTime.Now.Date; //assign data to property allPolicies.ThisPolicy = testPolicy; //check if same Assert.AreEqual(allPolicies.ThisPolicy, testPolicy); }
public void ListAndCountOk() { //instance of class var allPolicies = new clsPolicyCollection(); //create test data to assign to property as list of objects var testList = new List <clsPolicy>(); //add item to list and create the item of the test data var testItem = new clsPolicy(); //set properties of test item testItem.Accepted = true; testItem.CustomerId = 11; testItem.PolicyDetails = "Lorem ipsum dolor sit amet,"; testItem.PolicyId = 2; testItem.Price = 64.00M; testItem.StaffId = 68; testItem.StartDate = DateTime.Now.Date; //add the test item to list testList.Add(testItem); //assign the data to property allPolicies.PolicyList = testList; //test to see if the values are the same Assert.AreEqual(allPolicies.Count, testList.Count); }