public void ValidMethodOk() { var aPolicy = new clsPolicy(); var error = aPolicy.Valid(StaffId, CustomerId, PolicyDetails, StartDate, Price); Assert.AreEqual(error, ""); }
protected void BtnFind_Click(object sender, EventArgs e) { var aPolicy = new clsPolicy(); int PolicyIdTemp; if (!int.TryParse(txtPolicyId.Text, out PolicyIdTemp)) { lblError.Text = string.Format("<br /><b>PolicyID: {0}</b> is not Integer!", txtPolicyId.Text); } else { PolicyId = PolicyIdTemp; Session["PolicyId"] = PolicyId; var Found = aPolicy.Find(PolicyId); if (!Found) { string errorString = string.Format("<br /><b>PolicyID: {0}</b> Not In DB. Try a different PolicyID!<br />", PolicyId); lblError.Text = errorString; return; } txtPolicyId.Text = aPolicy.PolicyId.ToString(); txtStaffId.Text = aPolicy.StaffId.ToString(); txtCustomerId.Text = aPolicy.CustomerId.ToString(); txtPolicyDetails.Text = aPolicy.PolicyDetails; txtPrice.Text = aPolicy.Price.ToString(); chkAccepted.Checked = aPolicy.Accepted; calStartDate.VisibleDate = aPolicy.StartDate; calStartDate.SelectedDate = aPolicy.StartDate; } }
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 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 PriceNoMinLessOne() { var aPolicy = new clsPolicy(); const string Price = ""; var error = aPolicy.Valid(StaffId, CustomerId, PolicyDetails, StartDate, Price); Assert.AreNotEqual(error, ""); }
public void InstanceOk() { //Instantiate The class var aPolicy = new clsPolicy(); //test if exists Assert.IsNotNull(aPolicy); }
public void PolicyDetailsMinPlusOne() { var aPolicy = new clsPolicy(); const string PolicyDetails = "a"; var error = aPolicy.Valid(StaffId, CustomerId, PolicyDetails, StartDate, Price); Assert.AreEqual(error, ""); }
public void PolicyDetailsMid() { var aPolicy = new clsPolicy(); string PolicyDetails = ""; PolicyDetails = PolicyDetails.PadRight(5000, 'a'); var error = aPolicy.Valid(StaffId, CustomerId, PolicyDetails, StartDate, Price); Assert.AreEqual(error, ""); }
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; } }
public void PriceMaxLessOne() { //create an instance of the class we want to create var aPolicy = new clsPolicy(); //create some test data to pass to the method const string Price = "999999.98"; //this should be ok var error = aPolicy.Valid(StaffId, CustomerId, PolicyDetails, StartDate, Price); //test to see that the result is correct Assert.AreEqual(error, ""); }
public void PriceMoreThan2Decimals() { //create an instance of the class we want to create var aPolicy = new clsPolicy(); //create some test data to pass to the method const string Price = "1.001"; //this should be fail var error = aPolicy.Valid(StaffId, CustomerId, PolicyDetails, StartDate, Price); //test to see that the result is correct Assert.AreNotEqual(error, ""); }
public void CustomerIdMaxPlusOne() { //create an instance of the class we want to create var aPolicy = new clsPolicy(); //create some test data to pass to the method const string CustomerId = "2147483648"; //this should be fail var error = aPolicy.Valid(StaffId, CustomerId, PolicyDetails, StartDate, Price); //test to see that the result is correct Assert.AreNotEqual(error, ""); }
public void StartDatePropertyOk() { //Instantiate The class var aPolicy = new clsPolicy(); //test data var testData = DateTime.Now.Date; //assign to the property aPolicy.StartDate = testData; //test for equality Assert.AreEqual(aPolicy.StartDate, testData); }
public void AcceptedPropertyOk() { //Instantiate The class var aPolicy = new clsPolicy(); //test data const bool testData = true; //assign the data to property aPolicy.Accepted = testData; //test equality Assert.AreEqual(aPolicy.Accepted, testData); }
public void PricePropertyOK() { //Instantiate The class var aPolicy = new clsPolicy(); //test data const decimal testData = 1.11M; //assign to the property aPolicy.Price = testData; //test for equality Assert.AreEqual(aPolicy.Price, testData); }
public void PolicyDetailsPropertyOK() { //Instantiate The class var aPolicy = new clsPolicy(); //test data const string testData = "Some details"; //assign to the property aPolicy.PolicyDetails = testData; //test for equality Assert.AreEqual(aPolicy.PolicyDetails, testData); }
public void CustomerIDPropertyOK() { //Instantiate The class var aPolicy = new clsPolicy(); //test data const int testData = 1; //assign to the property aPolicy.CustomerId = testData; //test for equality Assert.AreEqual(aPolicy.CustomerId, testData); }
protected void Page_Load(object sender, EventArgs e) { var APolicy = new clsPolicy(); APolicy = (clsPolicy)Session["APolicy"]; Response.Write(APolicy.PolicyId + "<br />"); Response.Write(APolicy.StaffId + "<br />"); Response.Write(APolicy.CustomerId + "<br />"); Response.Write(APolicy.PolicyDetails + "<br />"); Response.Write(APolicy.Price + "<br />"); Response.Write(APolicy.StartDate + "<br />"); Response.Write(APolicy.Accepted + "<br />"); }
public void FindMethodOK() { //Instantiate The class var aPolicy = new clsPolicy(); //test data const int PolicyId = 7; //boolean var to store the result of the validation //invoke the method var Found = aPolicy.Find(PolicyId); //test for equality Assert.IsTrue(Found); }
public void StartDateExtremeMin() { //create an instance of the class we want to create var aPolicy = new clsPolicy(); //create variable to store the test date data and set it to today var testDate = DateTime.Now.Date; //change the date to -100 years testDate = testDate.AddYears(-100); //convert to string string StartDate = testDate.ToString(); //invoke the method var error = aPolicy.Valid(StaffId, CustomerId, PolicyDetails, StartDate, Price); //test to see that the result is correct Assert.AreNotEqual(error, ""); }
public void StartDateMin() { //create an instance of the class we want to create clsPolicy aPolicy = new clsPolicy(); //string variable to store any error message String Error = ""; //create a variable to store the test date data DateTime TestDate; //set the date totodays date TestDate = DateTime.Now.Date; //convert the date variable to a string variable string StartDate = TestDate.ToString(); //invoke the method Error = aPolicy.Valid(StaffId, CustomerId, PolicyDetails, StartDate, Price); //test to see that the result is correct Assert.AreEqual(Error, ""); }
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 TestPriceFound() { //Instantiate The class var aPolicy = new clsPolicy(); //boolean var to record if data is OK (assume it is) var OK = true; //test data const int PolicyId = 7; //boolean car to store the result of search //invoke method _ = aPolicy.Find(PolicyId); //check the policy id if (aPolicy.Price != 99.64M) { OK = false; } //test to see the result is correct Assert.IsTrue(OK); }
public void TestPolicyDetailsFound() { //Instantiate The class var aPolicy = new clsPolicy(); //boolean var to record if data is OK (assume it is) var OK = true; //test data const int PolicyId = 7; //boolean car to store the result of search //invoke method _ = aPolicy.Find(PolicyId); //check the policy id if (aPolicy.PolicyDetails != "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.") { OK = false; } //test to see the result is correct Assert.IsTrue(OK); }
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); }