public void AddPropertyOK() { clsShippingCollection AllShipments = new clsShippingCollection(); //create item of test data clsShipping TestShipment = new clsShipping(); //store primary key Int32 PrimaryKey = 0; //set its properties TestShipment.ShippingId = 1; TestShipment.ShippingType = "Standard"; TestShipment.Price = 4.99m; TestShipment.DateOfDispatch = DateTime.Now.Date; TestShipment.Dispatched = true; //set ThisItem to test data AllShipments.ThisShipment = TestShipment; //add record PrimaryKey = AllShipments.Add(); //set primary key of test data TestShipment.ShippingId = PrimaryKey; //find record AllShipments.ThisShipment.Find(PrimaryKey); //test to see values are same Assert.AreEqual(AllShipments.ThisShipment, TestShipment); }
public void UpdateMethodOK() { clsShippingCollection AllShipments = new clsShippingCollection(); //create item of test data clsShipping TestShipment = new clsShipping(); //store primary key Int32 PrimaryKey = 0; //set its properties TestShipment.ShippingType = "Standard"; TestShipment.Price = 4.99m; TestShipment.DateOfDispatch = DateTime.Now.Date; TestShipment.Dispatched = true; //set ThisItem to test data AllShipments.ThisShipment = TestShipment; //add record PrimaryKey = AllShipments.Add(); //set primary key of test data TestShipment.ShippingId = PrimaryKey; //modify test data TestShipment.ShippingType = "Express"; TestShipment.Price = 7.99m; TestShipment.DateOfDispatch = Convert.ToDateTime("2021-04-27"); TestShipment.Dispatched = true; //set record based on new test data AllShipments.ThisShipment = TestShipment; //update record AllShipments.Update(); //find record AllShipments.ThisShipment.Find(PrimaryKey); //test to see ThisItem matches test data Assert.AreEqual(AllShipments.ThisShipment, TestShipment); }
public void DeleteMethodOK() { clsShippingCollection AllShipments = new clsShippingCollection(); //create item of test data clsShipping TestShipment = new clsShipping(); //store primary key Int32 PrimaryKey = 0; //set its properties TestShipment.ShippingType = "Standard"; TestShipment.Price = 4.99m; TestShipment.DateOfDispatch = DateTime.Now.Date; TestShipment.Dispatched = true; //set ThisItem to test data AllShipments.ThisShipment = TestShipment; //add record PrimaryKey = AllShipments.Add(); //set primary key of test data TestShipment.ShippingId = PrimaryKey; //find record AllShipments.ThisShipment.Find(PrimaryKey); //delete record AllShipments.Delete(); //find record now Boolean Found = AllShipments.ThisShipment.Find(PrimaryKey); //test to see record was not found Assert.IsFalse(Found); }
void DisplayAllShipments() { clsShippingCollection AllShipments = new clsShippingCollection(); lstShippingList.DataSource = AllShipments.ShippingList; lstShippingList.DataValueField = "ShippingId"; lstShippingList.DataTextField = "ShippingId";//what to show on the list box lstShippingList.DataBind(); }
public void ReportByDispatchStatusOK() { clsShippingCollection AllShipments = new clsShippingCollection(); //create an instance of filtered data clsShippingCollection FilteredShipments = new clsShippingCollection(); //apply true value (will be different from original list) FilteredShipments.ReportByDispatchedTrue(); //test to see two values are not the same Assert.AreNotEqual(AllShipments.Count, FilteredShipments.Count); }
private void DisplayShipment() { clsShippingCollection AllShipments = new clsShippingCollection(); AllShipments.ThisShipment.Find(ShippingId); txtShippingId.Text = AllShipments.ThisShipment.ShippingId.ToString(); lstShippingType.SelectedValue = AllShipments.ThisShipment.ShippingType; txtPrice.Text = AllShipments.ThisShipment.Price.ToString(); txtDateOfDispatch.Text = AllShipments.ThisShipment.DateOfDispatch.ToString(); }
protected void btnYes_Click(object sender, EventArgs e) { //create new instance of clsStockCollection clsShippingCollection AllShipments = new clsShippingCollection(); //find record to delete AllShipments.ThisShipment.Find(ShippingId); //delete record AllShipments.Delete(); //redirect to main page Response.Redirect("ShippingList.aspx"); }
protected void btnAllOrders_Click(object sender, EventArgs e) { clsShippingCollection Shipments = new clsShippingCollection(); Shipments.ClearFilter(); lstShippingList.DataSource = Shipments.ShippingList; //set name of primary key lstShippingList.DataValueField = "ShippingId"; //set name of field to display lstShippingList.DataTextField = "ShippingId"; //bind data to the list lstShippingList.DataBind(); }
protected void btnDispatched_Click(object sender, EventArgs e) { clsShippingCollection Shipments = new clsShippingCollection(); Shipments.ReportByDispatchedTrue(); lstShippingList.DataSource = Shipments.ShippingList; //set name of primary key lstShippingList.DataValueField = "ShippingId"; //set name of field to display lstShippingList.DataTextField = "ShippingId"; //bind data to the list lstShippingList.DataBind(); }
public void ThisShipmentPropertyOK() { clsShippingCollection AllShipments = new clsShippingCollection(); //create test data in the form of a list of objects to assign to the property clsShipping TestShipment = new clsShipping(); TestShipment.ShippingId = 1; TestShipment.ShippingType = "Standard"; TestShipment.Price = 4.99m; TestShipment.DateOfDispatch = DateTime.Now.Date; TestShipment.Dispatched = true; AllShipments.ThisShipment = TestShipment; Assert.AreEqual(AllShipments.ThisShipment, TestShipment); }
public void ListAndCountOK() { clsShippingCollection AllShipments = new clsShippingCollection(); //create test data in the form of a list of objects to assign to the property List <clsShipping> TestList = new List <clsShipping>(); clsShipping TestShipment = new clsShipping(); TestShipment.ShippingId = 1; TestShipment.ShippingType = "Standard"; TestShipment.Price = 4.99m; TestShipment.DateOfDispatch = DateTime.Now.Date; TestShipment.Dispatched = true; TestList.Add(TestShipment); AllShipments.ShippingList = TestList; Assert.AreEqual(AllShipments.Count, TestList.Count); }
public void InstanceOK() { clsShippingCollection AllShipments = new clsShippingCollection(); Assert.IsNotNull(AllShipments); }
protected void btnOK_Click(object sender, EventArgs e) { lblError.Text = ""; clsShipping AShipment = new clsShipping(); string ShippingType = lstShippingType.Text; string Price = txtPrice.Text; string DateOfDispatch = txtDateOfDispatch.Text; //Error message String Error = ""; Error = AShipment.Valid(DateOfDispatch); if (lstShippingType.SelectedIndex == 0) { Error += "Select a Shipping Type : "; } if (Error == "") { //capture properties AShipment.ShippingId = ShippingId; AShipment.ShippingType = ShippingType; //populate Price field based on Shipping Type selection if (lstShippingType.SelectedIndex == 1 || lstShippingType.SelectedIndex == 2) { AShipment.Price = Decimal.Parse(Price); } //define value of Dispatched boolean based on if a date of dispatch was input if (DateOfDispatch.Length == 0) { DateOfDispatch = null; AShipment.Dispatched = false; } else { AShipment.DateOfDispatch = Convert.ToDateTime(DateOfDispatch); AShipment.Dispatched = true; } clsShippingCollection ShippingList = new clsShippingCollection(); if (ShippingId == -1) { ShippingList.ThisShipment = AShipment; ShippingList.Add(); } else { ShippingList.ThisShipment.Find(ShippingId); ShippingList.ThisShipment = AShipment; ShippingList.Update(); } Response.Redirect("ShippingList.aspx"); } else { lblError.Text = Error; } }