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); }
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 ValidMethodOK() { clsShipping AShipment = new clsShipping(); String Error = ""; Error = AShipment.Valid(DateOfDispatch); Assert.AreEqual(Error, ""); }
public void DispatchedPropertyOK() { clsShipping AShipment = new clsShipping(); Boolean TestData = true; AShipment.Dispatched = TestData; Assert.AreEqual(AShipment.Dispatched, TestData); }
public void ShippingPricePropertyOK() { clsShipping AShipment = new clsShipping(); decimal TestData = 5.75m; //the m = a decimal. AShipment.Price = TestData; Assert.AreEqual(AShipment.Price, TestData); }
public void DateOfDispatchPropertyOK() { clsShipping AShipment = new clsShipping(); DateTime TestData = new DateTime(2021, 1, 15); AShipment.DateOfDispatch = TestData; Assert.AreEqual(AShipment.DateOfDispatch, TestData); }
public void ShippingTypePropertyOK() { clsShipping AShipment = new clsShipping(); string TestData = "Standard"; AShipment.ShippingType = TestData; Assert.AreEqual(AShipment.ShippingType, TestData); }
public void ShippingIdPropertyOK() { clsShipping AShipment = new clsShipping(); int TestData = 1; AShipment.ShippingId = TestData; Assert.AreEqual(AShipment.ShippingId, TestData); }
public void FindOK() { clsShipping AShipment = new clsShipping(); Boolean Found = false; int ShippingId = 5; Found = AShipment.Find(ShippingId); Assert.IsTrue(Found); }
public void DateOfDispatchInvalidData() { clsShipping AShipment = new clsShipping(); String Error = ""; //set the DateOfDispatch to a non date value String DateOfDispatch = "invalid input"; Error = AShipment.Valid(DateOfDispatch); Assert.AreNotEqual(Error, ""); //should fail }
protected void Page_Load(object sender, EventArgs e) { clsShipping AShipment = new clsShipping(); AShipment = (clsShipping)Session["AShipment"]; Response.Write(AShipment.ShippingId); Response.Write(AShipment.ShippingType); Response.Write(AShipment.Price); Response.Write(AShipment.DateOfDispatch); Response.Write(AShipment.Dispatched); }
public void DateOfDispatchMinLessOne() { clsShipping AShipment = new clsShipping(); String Error = ""; //store the minimum date DateTime MinimumDate = Convert.ToDateTime("2015-01-01"); //set date to MinimumDate subtract 1 day String DateOfDispatch = MinimumDate.AddDays(-1).ToString(); Error = AShipment.Valid(DateOfDispatch); Assert.AreNotEqual(Error, ""); //should fail }
public void DateOfDispatchMinPlusOne() { clsShipping AShipment = new clsShipping(); String Error = ""; //store the minimum date DateTime MinimumDate = Convert.ToDateTime("2015-01-01"); //set date to MinimumDate plus 1 day. String DateOfDispatch = MinimumDate.AddDays(1).ToString(); Error = AShipment.Valid(DateOfDispatch); Assert.AreEqual(Error, ""); //should pass }
public void TestDateOfDispatchFound() { clsShipping AShipment = new clsShipping(); Boolean Found = false; Boolean OK = true; int ShippingId = 8; Found = AShipment.Find(ShippingId); if (AShipment.DateOfDispatch != Convert.ToDateTime("20/04/2021")) { OK = false; } Assert.IsTrue(OK); }
public void DateOfDispatchMid() { clsShipping AShipment = new clsShipping(); String Error = ""; //create test data to pass to the method DateTime TestDate; //set date to Today's date TestDate = DateTime.Now.Date; //set the date to a bit in the past TestDate = TestDate.AddYears(-5); Error = AShipment.Valid(DateOfDispatch); Assert.AreEqual(Error, ""); //should pass }
public void TestDispatchedFound() { clsShipping AShipment = new clsShipping(); Boolean Found = false; Boolean OK = true; int ShippingId = 8; Found = AShipment.Find(ShippingId); if (AShipment.Dispatched != true) { OK = false; } Assert.IsTrue(OK); }
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 TestShippingIdFound() { clsShipping AShipment = new clsShipping(); Boolean Found = false; Boolean OK = true; int ShippingId = 5; Found = AShipment.Find(ShippingId); if (AShipment.ShippingId != 5) { OK = false; } Assert.IsTrue(OK); }
public void DateOfDispatchMax() { clsShipping AShipment = new clsShipping(); String Error = ""; //create test data to pass to the method DateTime TestDate; //set date to Today's date TestDate = DateTime.Now.Date; //convert the date to a string String DateOfDispatch = TestDate.ToString(); Error = AShipment.Valid(DateOfDispatch); Assert.AreEqual(Error, ""); //should pass }
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 DateOfDispatchMaxPlusOne() { clsShipping AShipment = new clsShipping(); String Error = ""; //create test data to pass to the method DateTime TestDate; //set date to Today's date TestDate = DateTime.Now.Date; //change the date to tomorrow's date TestDate = TestDate.AddDays(1); //convert the date to a string String DateOfDispatch = TestDate.ToString(); Error = AShipment.Valid(DateOfDispatch); Assert.AreNotEqual(Error, ""); //should fail }
public void DateOfDispatchExtremeMin() { clsShipping AShipment = new clsShipping(); String Error = ""; //create test data to pass to the method DateTime TestDate; //set date to Today's date TestDate = DateTime.Now.Date; //change the date to - 100 years TestDate = TestDate.AddYears(-100); //convert the date to a string String DateOfDispatch = TestDate.ToString(); Error = AShipment.Valid(DateOfDispatch); Assert.AreNotEqual(Error, ""); //should fail }
protected void lstShippingType_SelectedIndexChanged(object sender, EventArgs e) { clsShipping AShipment = new clsShipping(); if (lstShippingType.SelectedIndex == 1) { AShipment.Price = 4.99m; txtPrice.Text = "4.99"; } else if (lstShippingType.SelectedIndex == 2) { AShipment.Price = 7.99m; txtPrice.Text = "7.99"; } else { txtPrice.Text = ""; } }
protected void btnFind_Click(object sender, EventArgs e) { lblError.Text = ""; clsShipping AShipment = new clsShipping(); Int32 ShippingId; Boolean Found = false; ShippingId = Convert.ToInt32(txtShippingId.Text); Found = AShipment.Find(ShippingId); if (Found == true) { lstShippingType.SelectedValue = AShipment.ShippingType; txtPrice.Text = AShipment.Price.ToString(); if (txtDateOfDispatch.Text == null) { //do nothing } else { txtDateOfDispatch.Text = AShipment.DateOfDispatch.ToString(); } } else { //reset the text boxes to empty txtShippingId.Text = ""; lstShippingType.SelectedIndex = 0; txtPrice.Text = ""; txtDateOfDispatch.Text = ""; //output an error message lblError.Text = "Error! Item does not exist"; } }
public void InstanceOK() { clsShipping AShipment = new clsShipping(); Assert.IsNotNull(AShipment); }
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; } }