public void DeletePaymentMethodOK() { //Create an instance of the class we want to create clsSTPaymentCollection AllPayments = new clsSTPaymentCollection(); //Create an item of test data clsSTPayment PaymentTestItem = new clsSTPayment(); //Var to store the primary key Int32 PrimaryKey = 0; //Set its properties PaymentTestItem.CardNumber = "1234567891234567"; PaymentTestItem.AccountNumber = "12345678"; PaymentTestItem.SortCode = "123456"; PaymentTestItem.ExpiryDate = "12/22"; PaymentTestItem.ValidFrom = "12/19"; PaymentTestItem.CardHolderName = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM"; PaymentTestItem.CVC = "123"; //Set this ThisPayment to the test data AllPayments.ThisPayment = PaymentTestItem; //Add the record PrimaryKey = AllPayments.Add(); //Set the primary key of the test data PaymentTestItem.PaymentID = PrimaryKey; //search the payment record AllPayments.ThisPayment.Find(PrimaryKey); //Delete the record AllPayments.Delete(); //Now found the payment record Boolean Found = AllPayments.ThisPayment.Find(PrimaryKey); //test to see that the two values are the same Assert.IsFalse(Found); }
void Add() { //Create an instance of the payment book clsSTPaymentCollection PaymentBook = new clsSTPaymentCollection(); //Validate the data on the web form string Error = PaymentBook.ThisPayment.Valid(TextBoxCardNumber.Text, TextBoxAccountNumber.Text, TextBoxSortCode.Text, TextBoxExpiryDate.Text, TextBoxValidFrom.Text, TextBoxCardHolderName.Text, TextBoxCVC.Text); //If the data is ok then add it to the object if (Error == "") { //Get the data entered by the user PaymentBook.ThisPayment.CardNumber = TextBoxCardNumber.Text; PaymentBook.ThisPayment.AccountNumber = TextBoxAccountNumber.Text; PaymentBook.ThisPayment.SortCode = TextBoxSortCode.Text; PaymentBook.ThisPayment.ExpiryDate = TextBoxExpiryDate.Text; PaymentBook.ThisPayment.ValidFrom = TextBoxValidFrom.Text; PaymentBook.ThisPayment.CardHolderName = TextBoxCardHolderName.Text; PaymentBook.ThisPayment.CVC = TextBoxCVC.Text; //Add the payment record PaymentBook.Add(); //All done so redirect to the home payment page Response.Redirect("Payment.aspx"); } else { //Report an error LableError.Text = "There was a problem with the payment method you tried adding" + Error; } }
public void UpdatePaymentMethodOK() { //Create an instance of the class we want to create clsSTPaymentCollection AllPayments = new clsSTPaymentCollection(); //Create an item of test data clsSTPayment PaymentTestItem = new clsSTPayment(); //Var to store the primary key Int32 PrimaryKey = 0; //Set its properties PaymentTestItem.CardNumber = "1234567891234567"; PaymentTestItem.AccountNumber = "12345678"; PaymentTestItem.SortCode = "123456"; PaymentTestItem.ExpiryDate = "12/22"; PaymentTestItem.ValidFrom = "12/19"; PaymentTestItem.CardHolderName = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM"; PaymentTestItem.CVC = "123"; //Set this ThisPayment to the test data AllPayments.ThisPayment = PaymentTestItem; //Add the payment record PrimaryKey = AllPayments.Add(); //Set the primary key of the test data PaymentTestItem.PaymentID = PrimaryKey; //Modify the test data PaymentTestItem.CardNumber = "1234567891234568"; PaymentTestItem.AccountNumber = "12345679"; PaymentTestItem.SortCode = "123457"; PaymentTestItem.ExpiryDate = "12/23"; PaymentTestItem.ValidFrom = "12/20"; PaymentTestItem.CardHolderName = "I HATE PROJECT MANAGEMENT"; PaymentTestItem.CVC = "124"; //Set the record based on the new test data AllPayments.ThisPayment = PaymentTestItem; //Update the record AllPayments.Update(); //Find the record AllPayments.ThisPayment.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllPayments.ThisPayment, PaymentTestItem); }