public void InstanceOK() { //creating an instance of a class we want to create clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); //test if it exists Assert.IsNotNull(AllOrderLines); //create a list of objects List <clsOrderLine> TestList = new List <clsOrderLine>(); //add an intem into the list //create the item of test data clsOrderLine TestItem = new clsOrderLine(); //set its properties TestItem.OrderId = 1; TestItem.ProductId = "123abc"; TestItem.Price = 24.99; TestItem.Quantity = 3; TestItem.Available = true; //add the item to the test list TestList.Add(TestItem); //assign data to property AllOrderLines.OrderLineList = TestList; //test if values are the same Assert.AreEqual(AllOrderLines.OrderLineList, TestList); }
public void OrderLineListOK() { //create an instance of the class we want to create clsOrderLineCollection AllOrders = new clsOrderLineCollection(); //create test data to assign to the property //data needs to be a list of objects List <clsOrderLine> TestList = new List <clsOrderLine>(); //add item to the list //create the item of test data clsOrderLine TestItem = new clsOrderLine(); //set its properties TestItem.OrderLineID = 2; TestItem.OrderNo = 2; TestItem.TrainerID = 2; TestItem.OrderLineID = 2; TestItem.OrderQty = 1; TestItem.Price = 2; //add the item to the list TestList.Add(TestItem); //assign the data to the property AllOrders.OrderLineList = TestList; //test to see that the two values are the same Assert.AreEqual(AllOrders.OrderLineList, TestList); }
public void AddMethodOK() { //create an instance of the class we want to create clsOrderLineCollection AllOrders = new clsOrderLineCollection(); //create the item of test data clsOrderLine TestItem = new clsOrderLine(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.OrderLineID = 2; TestItem.OrderNo = 2; TestItem.TrainerID = 2; TestItem.OrderLineID = 2; TestItem.OrderQty = 1; TestItem.Price = 2; //set ThisOrder to the test data AllOrders.ThisOrderLine = TestItem; //add the record PrimaryKey = AllOrders.Add(); //set the primary key to the test data TestItem.OrderNo = PrimaryKey; //find the record AllOrders.ThisOrderLine.Find(PrimaryKey); //test to see that two values are the same Assert.AreEqual(AllOrders.ThisOrderLine, TestItem); }
private void btnEdit_Click(object sender, EventArgs e) { //var to store the primary key value of the record to be deleted Int32 OrderLineID; //if a record has been selected from the list if (lstOrderLine.SelectedIndex != -1) { //get the primary key value of the record to delete OrderLineID = Convert.ToInt32(lstOrderLine.SelectedValue); //find the record to edit //we need to use our collection class clsOrderLineCollection AllOrders = new clsOrderLineCollection(); AllOrders.ThisOrderLine.Find(OrderLineID); //display the data for record with chosen OrderNo txtTrainerID.Text = AllOrders.ThisOrderLine.TrainerID.ToString(); txtOrderNo.Text = AllOrders.ThisOrderLine.OrderNo.ToString(); txtPrice.Text = AllOrders.ThisOrderLine.Price.ToString(); txtQuantity.Text = AllOrders.ThisOrderLine.OrderQty.ToString(); } else { //display an error lblError1.Text = "You must select an item from the list to edit it."; } }//end of edit
public void UpdateMethodOk() { clsOrderLineCollection AllLines = new clsOrderLineCollection(); clsOrderLine TestItem = new clsOrderLine(); Int32 PrimaryKey = 0; TestItem.OrderLineId = 1; TestItem.OrderId = 1; TestItem.ItemNo = 1; TestItem.ItemDescription = "Test Item"; TestItem.Quantity = 1; TestItem.UnitCost = 15; AllLines.ThisOrderLine = TestItem; PrimaryKey = AllLines.Add(); TestItem.OrderLineId = PrimaryKey; TestItem.OrderId = 2; TestItem.ItemNo = 8; TestItem.ItemDescription = "Test Item 2"; TestItem.Quantity = 2; TestItem.UnitCost = 25; AllLines.ThisOrderLine = TestItem; AllLines.Update(); AllLines.ThisOrderLine.Find(PrimaryKey); Assert.AreEqual(AllLines.ThisOrderLine, TestItem); }
public void ReportByCustomerNameNoneFound() { clsOrderLineCollection FilteredOrderLines = new clsOrderLineCollection(); FilteredOrderLines.ReportByCustomerName("xxxxxx xxxxxx"); Assert.AreEqual(0, FilteredOrderLines.Count); }
public void DeleteMethodOK() { //instance of class clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); //create item for test data clsOrderLine TestItem = new clsOrderLine(); //var to store the primary key Int32 PrimaryKey = 0; //set properties TestItem.OrderId = 1; TestItem.ProductId = "123abc"; TestItem.Price = 24.99; TestItem.Quantity = 3; TestItem.Available = true; //set ThisOrder to the test data AllOrderLines.ThisOrderLine = TestItem; //add the record PrimaryKey = AllOrderLines.Add(); //set the primary key of the test data TestItem.OrderId = PrimaryKey; //find the record AllOrderLines.ThisOrderLine.Find(PrimaryKey); //delete the record AllOrderLines.Delete(); //now find the record Boolean Found = AllOrderLines.ThisOrderLine.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void ReportBySelectionDescriptionNoneFound() { clsOrderLineCollection FilteredOrderLines = new clsOrderLineCollection(); FilteredOrderLines.ReportBySelectionDescription("xxx xxx"); Assert.AreEqual(0, FilteredOrderLines.Count); }
public void FilterByOrderIDTestDataFound() { //create an instance of the filtered data clsOrderLineCollection FilteredOrderLines = new clsOrderLineCollection(); //var to store outcome Boolean OK = true; //apply a OrderID that doesn't exist FilteredOrderLines.FilterByOrderID("1"); //checked that the correct number of records ar found if (FilteredOrderLines.OrderLineList.Count == 2) { //check that the first record is ID 1 if (FilteredOrderLines.OrderLineList[0].OrderLineID != 1) { OK = false; } //check that the first record is ID 2 if (FilteredOrderLines.OrderLineList[1].OrderLineID != 2) { OK = false; } } else { OK = false; } //test to see that there are no records Assert.IsTrue(OK); }
public void AddMethodOK() { //instance of class clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); //create item for test data clsOrderLine TestItem = new clsOrderLine(); //var to store the primary key Int32 PrimaryKey = 0; //set properties TestItem.OrderId = 1; TestItem.ProductId = "123abc"; TestItem.Price = 24.99; TestItem.Quantity = 3; TestItem.Available = true; //set ThisOrder to the test data AllOrderLines.ThisOrderLine = TestItem; //add the record PrimaryKey = AllOrderLines.Add(); //set the primary key of the test data TestItem.OrderId = PrimaryKey; //find the record AllOrderLines.ThisOrderLine.Find(PrimaryKey); //test if values are the same Assert.AreEqual(AllOrderLines.ThisOrderLine, TestItem); }
public void DeleteMethodOK() { //create class instance clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); // create test data clsOrderLine TestItem = new clsOrderLine(); // primary key variable Int32 PrimaryKey = 0; // set properties TestItem.orderID = 1; TestItem.orderLineID = 1; TestItem.staffID = 1; TestItem.orderComplete = true; //set this order to the test data AllOrderLines.ThisOrderLine = TestItem; // add record PrimaryKey = AllOrderLines.Add(); // set primary key of test data TestItem.orderLineID = PrimaryKey; // find record AllOrderLines.ThisOrderLine.Find(PrimaryKey); // delete record AllOrderLines.Delete(); // find the record again Boolean Found = AllOrderLines.ThisOrderLine.Find(PrimaryKey); // test that record was not found Assert.IsFalse(Found); }
public void DeleteMethodOK() { clsOrderLineCollection orderLines = new clsOrderLineCollection(); clsOrderLine orderLine = new clsOrderLine { OrderId = 3, OrderLineId = 1, ProductId = 1, Quantity = 5 }; Int32 primaryKey = 0; orderLines.ThisOrderLine = orderLine; primaryKey = orderLines.Add(); orderLine.OrderLineId = primaryKey; orderLines.ThisOrderLine.find(primaryKey); orderLines.Delete(); Assert.IsFalse(orderLines.ThisOrderLine.find(primaryKey)); }
public void UpdateMethodOK() { //create an instance of the class we want to create clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); //create the item of test data clsOrderLine TestItem = new clsOrderLine(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.OrderID = "5"; TestItem.ProductID = "5"; //set ThisOrder to the test data AllOrderLines.ThisOrderLine = TestItem; //add the record PrimaryKey = AllOrderLines.Add(); //set the primary key of the test data TestItem.OrderLineID = PrimaryKey; //modify the test data TestItem.OrderID = "6"; TestItem.ProductID = "6"; //set the record based on the new test data AllOrderLines.ThisOrderLine = TestItem; //update the record AllOrderLines.Update(); //fnd the record AllOrderLines.ThisOrderLine.Find(PrimaryKey); //test to see thisorderline matches the test data Assert.AreEqual(AllOrderLines.ThisOrderLine, TestItem); }
public void InstanceOK() { clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); Assert.IsNotNull(AllOrderLines); }
protected void btnOKOrderLine_Click(object sender, EventArgs e) { clsOrderLine AnOrderLine = new clsOrderLine(); string orderID = OrderIDFind.Text; string productID = ProductIDFind.Text; string selectionDescription = SelectionDescriptionFind.Text; string quantity = QuantityList.Text; string Error = ""; Error = AnOrderLine.Valid(orderID, productID, quantity, selectionDescription); if (Error == "") { AnOrderLine.orderID = Convert.ToInt32(OrderIDFind.Text); AnOrderLine.productID = Convert.ToInt32(ProductIDFind.Text); AnOrderLine.selectionDescription = SelectionDescriptionFind.Text; AnOrderLine.quantity = Convert.ToInt32(QuantityList.Text); clsOrderLineCollection OrderLineList = new clsOrderLineCollection(); if (OrderLineID == -1) { OrderLineList.ThisOrderLine = AnOrderLine; OrderLineList.Add(); } else { OrderLineList.ThisOrderLine.Find(OrderLineID); OrderLineList.ThisOrderLine = AnOrderLine; OrderLineList.Update(); } Response.Redirect("OrderLineList.aspx"); } else { Label2.Text = Error; } }
void Add() { //create instance of the class clsOrderLineCollection NewOrder = new clsOrderLineCollection(); //validate the data on the web form String Error = NewOrder.ThisOrderLine.Valid(txtTrainerID.Text, txtOrderNo.Text, txtQuantity.Text, ddlTrainerID.Text); if (Error == "") //string trainerID, string orderNo, string quantity, string price { //capture trainer ID NewOrder.ThisOrderLine.TrainerID = Convert.ToInt32(txtTrainerID.Text); //capture order no NewOrder.ThisOrderLine.OrderNo = Convert.ToInt32(txtOrderNo.Text); //capture quantity NewOrder.ThisOrderLine.OrderQty = Convert.ToInt32(txtQuantity.Text); //capture price NewOrder.ThisOrderLine.Price = Convert.ToInt32(ddlTrainerID.Text); NewOrder.Add(); lblError.Text = "New trainer was successfully added into your order!"; } else { //report error lblError.Text = "There were problems with the data entered: " + Error; } }
public void ReportByProductIdTestDataFound() { clsOrderLineCollection FilteredOrderLines = new clsOrderLineCollection(); //var to store the outcome Boolean OK = true; //apply a shipping method that doesn't exist FilteredOrderLines.ReportByProductId("yyy yyy"); //check that the correct number of records are found if (FilteredOrderLines.Count == 2) { //check that the first record is ID 1 if (FilteredOrderLines.OrderLineList[0].OrderId != 1) { OK = false; } //check that the first record is ID 2 if (FilteredOrderLines.OrderLineList[1].OrderId != 2) { OK = false; } } else { OK = false; } //test to see that there are no records Assert.IsTrue(OK); }
public void UpdateMethodOk() { // create instance of class to test clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); // create test data clsOrderLine TestItem = new clsOrderLine(); // primary key var Int32 PrimaryKey = 0; // set properties for test data TestItem.orderID = 1; TestItem.staffID = 1; TestItem.orderComplete = true; // set ThisAddress to the test data AllOrderLines.ThisOrderLine = TestItem; // add the record PrimaryKey = AllOrderLines.Add(); // set primary key of test data TestItem.orderLineID = PrimaryKey; // modify test data TestItem.orderID = 3; TestItem.staffID = 1; TestItem.orderComplete = true; // set record based on new test data AllOrderLines.ThisOrderLine = TestItem; // update the record AllOrderLines.Update(); // find record AllOrderLines.ThisOrderLine.Find(PrimaryKey); // test that ThisOrderLine matches the test data Assert.AreEqual(AllOrderLines.ThisOrderLine, TestItem); }
public void ReportBySelectionDescriptionTestDataFound() { clsOrderLineCollection FilteredOrderLines = new clsOrderLineCollection(); Boolean OK = true; FilteredOrderLines.ReportBySelectionDescription("Adidas"); if (FilteredOrderLines.Count == 3) { if (FilteredOrderLines.OrderLineList[0].orderLineID != 3) { OK = false; } if (FilteredOrderLines.OrderLineList[1].orderLineID != 13) { OK = false; } if (FilteredOrderLines.OrderLineList[2].orderLineID != 16) { OK = false; } } else { OK = false; } Assert.IsTrue(OK); }
public void DeleteMethodOK() { //create an instance of the class we want to create clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); //create the item of test data clsOrderLine TestItem = new clsOrderLine(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.OrderLineID = 5; TestItem.OrderID = "5"; TestItem.ProductID = "5"; //set ThisOrder to the test data AllOrderLines.ThisOrderLine = TestItem; //add the record PrimaryKey = AllOrderLines.Add(); //set the primary key of the test data TestItem.OrderLineID = PrimaryKey; //Find the record AllOrderLines.ThisOrderLine.Find(PrimaryKey); //delete the record AllOrderLines.Delete(); //now find the record Boolean Found = AllOrderLines.ThisOrderLine.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void AddMethodOK() { //create class instance clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); // create test data clsOrderLine TestItem = new clsOrderLine(); // primary key variable Int32 PrimaryKey = 0; // set properties TestItem.orderLineID = 1; TestItem.orderID = 1; TestItem.staffID = 1; TestItem.orderComplete = true; //set this order to the test data AllOrderLines.ThisOrderLine = TestItem; // add record PrimaryKey = AllOrderLines.Add(); // set primary key of test data TestItem.orderLineID = PrimaryKey; // find record AllOrderLines.ThisOrderLine.Find(PrimaryKey); // test values are the same Assert.AreEqual(AllOrderLines.ThisOrderLine, TestItem); }
public void InstanceOK() { //create an instance of the class we want to create clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); //test to see that it exists Assert.IsNotNull(AllOrderLines); }
protected void btnClear_Click(object sender, EventArgs e) { // instance of orderline collection clsOrderLineCollection OrderLines = new clsOrderLineCollection(); DisplayOrderLines(); txtFilter.Text = ""; }
public void InstanceOk() { // create instance to test clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); // test that instance exists Assert.IsNotNull(AllOrderLines); }
protected void btnYes_Click(object sender, EventArgs e) { clsOrderLineCollection OrderLines = new clsOrderLineCollection(); OrderLines.ThisOrderLine.Find(OrderLineID); OrderLines.Delete(); Response.Redirect("OrderLineList.aspx"); }
public void ReportByCustomerNameOK() { clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); clsOrderLineCollection FilteredOrderLines = new clsOrderLineCollection(); FilteredOrderLines.ReportByCustomerName(""); Assert.AreEqual(AllOrderLines.Count, FilteredOrderLines.Count); }
public void ReportBySelectionDescriptionMethodOK() { clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); clsOrderLineCollection FilteredOrderLines = new clsOrderLineCollection(); FilteredOrderLines.ReportBySelectionDescription(""); Assert.AreEqual(AllOrderLines.Count, FilteredOrderLines.Count); }
public void ReportByProductIdOK() { clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); clsOrderLineCollection FilterOrderLines = new clsOrderLineCollection(); FilterOrderLines.ReportByProductId(""); Assert.AreEqual(AllOrderLines.Count, FilterOrderLines.Count); }
protected void btnClear_Click(object sender, EventArgs e) { clsOrderLineCollection Lines = new clsOrderLineCollection(); lstOrderLineList.DataSource = Lines.OrderLineList; lstOrderLineList.DataValueField = "OrderLineId"; lstOrderLineList.DataTextField = "ItemDescription"; lstOrderLineList.DataBind(); }
protected void btnYes_Click(object sender, EventArgs e) { clsOrderLineCollection AddressBook = new clsOrderLineCollection(); AddressBook.ThisOrderLine.Find(TotalCost); AddressBook.Delete(); Response.Redirect("OrderLineList.aspx"); }