public void ShippingAddressMinPlusOne() { //create an instance of the class we want to create ClsOrder AnOrder = new ClsOrder(); //string variable to store any error message String Error = ""; //create some test data to pass to the method string ShippingAddress = "aa"; Error = AnOrder.Valid(OrderID, OrderDate, CustomerID, ShippingAddress); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void DateOfOrderExtremeMax() { ClsOrder AnOrder = new ClsOrder(); String Error = ""; DateTime TestDate; TestDate = DateTime.Now.Date; TestDate = TestDate.AddYears(100); string DateOfOrder = TestDate.ToString(); // This should fail Error = AnOrder.Valid(DateOfOrder, OrderPrice, OrderStatus); Assert.AreNotEqual(Error, ""); }
public void DateOfOrderMinPlusOne() { ClsOrder AnOrder = new ClsOrder(); String Error = ""; DateTime TestDate; TestDate = DateTime.Now.Date; TestDate = TestDate.AddDays(1); string DateOfOrder = TestDate.ToString(); // This should pass Error = AnOrder.Valid(DateOfOrder, OrderPrice, OrderStatus); Assert.AreNotEqual(Error, ""); }
public void CustomerIDExtremeMax() { //create an instance of the class we want to create ClsOrder AnOrder = new ClsOrder(); //string variable to store any error message String Error = ""; //create some test data to pass to the method string CustomerID = ""; CustomerID = CustomerID.PadRight(500, 'a'); Error = AnOrder.Valid(OrderID, OrderDate, CustomerID, ShippingAddress); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void CustomerIDMin() { //create an instance of the class we want to create ClsOrder AnOrder = new ClsOrder(); //string variable to store any error message String Error = ""; //string variable to store any error message string CustomerID = ""; //invoke the method Error = AnOrder.Valid(OrderID, OrderDate, CustomerID, ShippingAddress); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void NotesMinPlusOne() { //create an instance of the class we want to create ClsOrder AnOrder = new ClsOrder(); //string variable to store any error message String Error = ""; //create some test data to pass to the method String Notes = "aa"; //this should be ok //invoke the method Error = AnOrder.Valid(CustomerID, Notes, Date); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void CustomerIDExtremeMax() { //create an instance of the class we want to create ClsOrder AnOrder = new ClsOrder(); //string variable to store any error message String Error = ""; //create some test data to pass to the method String CustomerID = "2000"; //this should fail //invoke the method Error = AnOrder.Valid(CustomerID, Notes, Date); //test to see that the result is correct Assert.AreNotEqual(Error, ""); }
public void OrderDateMin() { //create an instance of the class we want to create ClsOrder AnOrder = new ClsOrder(); //string variable to store any error message String Error = ""; DateTime TestDate; TestDate = DateTime.Now.Date; string OrderDate = TestDate.ToString(); Error = AnOrder.Valid(OrderID, OrderDate, CustomerID, ShippingAddress); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void DateAddedMin() { //create an instance of the class we want to create ClsOrder AnOrder = new ClsOrder(); //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 Date = TestDate.ToString(); //invoke the method Error = AnOrder.Valid(CustomerID, Notes, Date); //test to see that the result is correct Assert.AreEqual(Error, ""); }
protected void btnSubmit_Click(object sender, EventArgs e) { // Old //ClsOrder AnOrder = new ClsOrder(); //AnOrder.OrderID = Convert.ToInt32(TxtOrderID.Text); //AnOrder.CustomerID = Convert.ToInt32(txtCustomerID.Text); //AnOrder.CarID = txtCar.Text; //AnOrder.DateOfOrder = Convert.ToDateTime(TxtDateOfOrder.Text); ////AnOrder.ServiceID = DropDownServices.SelectedValue; //Session["AnOrder"] = AnOrder; //Response.Redirect("OrderViewer.aspx"); // New ClsOrder AnOrder = new ClsOrder(); string orderID = TxtOrderID.Text; string DateOfOrder = TxtDateOfOrder.Text; string customerID = txtCustomerID.Text; string OrderPrice = txtPrice.Text; string OrderStatus = txtOrderStatus.Text; string Error = ""; Error = AnOrder.Valid(DateOfOrder, OrderPrice, OrderStatus); if (Error == "") { int OID = 0; bool canC = int.TryParse(orderID, out OID); if (canC == false) { AnOrder.OrderID = OrderID; } else { AnOrder.OrderID = Convert.ToInt32(TxtOrderID.Text); } int OIDC = 0; bool canCC = int.TryParse(customerID, out OIDC); if (canCC == false) { AnOrder.CustomerID = CustomerID; } else { AnOrder.CustomerID = Convert.ToInt32(txtCustomerID.Text); } AnOrder.CarID = Convert.ToInt32(DropDownCars.SelectedValue); AnOrder.DateOfOrder = Convert.ToDateTime(DateOfOrder); AnOrder.ServiceID = Convert.ToInt32(DropDownServices.SelectedValue); double price; price = Convert.ToDouble(OrderPrice); AnOrder.OrderPrice = price; AnOrder.OrderStatus = OrderStatus; AnOrder.PaymentID = Convert.ToInt32(TxtPaymentID.Text); AnOrder.Completed = CheckBoxCompleted.Checked; ClsOrderCollection OrderList = new ClsOrderCollection(); if (OrderID == -1) { OrderList.ThisOrder = AnOrder; OrderList.Add(); } else { OrderList.ThisOrder.Find(OrderID); OrderList.ThisOrder = AnOrder; OrderList.Update(); } Response.Redirect("OrderList.aspx"); } else { lblError.Text = Error; } }
protected void BtnOK_Click(object sender, EventArgs e) { //creates a new instance of ClsOrder ClsOrder AnOrder = new ClsOrder(); //capture the OrderID String OrderID = txtOrderID.Text; //capture the OrderDate string OrderDate = txtOrderDate.Text; //capture the CustomerID String CustomerID = txtCustomerID.Text; //capture the ShippingAddress string ShippingAddress = txtShippingAddress.Text; //variable to store any error messages string Error = ""; //validate the data Error = AnOrder.Valid(OrderID, OrderDate, CustomerID, ShippingAddress); if (Error == "") { //capture the OrderID AnOrder.OrderID = Convert.ToInt32(OrderID); //capture OrderDate AnOrder.OrderDate = Convert.ToDateTime(OrderDate); //capture the CustomerID AnOrder.CustomerID = Convert.ToInt32(CustomerID); //capture ShippingAddress AnOrder.ShippingAddress = ShippingAddress; //capture Order Shipped AnOrder.OrderShipped = chkOrderShipped.Checked; //creates new instance of OrderCollection ClsOrderCollection OrderList = new ClsOrderCollection(); //If this is a new record i.e OrderShipped = -1 the add the data if (OrderShipped == -1) { //Sets the ThisOrder property OrderList.ThisOrder = AnOrder; //adds new record OrderList.Add(); } //Otherwise it must be an update else { //find record to update OrderList.ThisOrder.Find(OrderShipped); //Sets the ThisOrder property OrderList.ThisOrder = AnOrder; //updates the record OrderList.Update(); } //redirects back to listpage Response.Redirect("OrderList.aspx"); } else { //display the error message lblError.Text = Error; } }