Ejemplo n.º 1
0
        public void StatusMaxLessOne()
        {
            //create an instance of the class that we want to create
            clsOrders AnOrder = new clsOrders();
            //string variable to store any error messages
            String Error = "";
            //create some test data to pass to the method
            string Status = "";

            Status = Status.PadRight(14, 'a');
            //invoke the method
            Error = AnOrder.Valid(CustomerId, ProductId, OrderDate, Description, Price, Status, DateShipped);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
Ejemplo n.º 2
0
        public void DescriptionExtremeMax()
        {
            //create an instance of the cloass we want to create
            clsOrders AnOrder = new clsOrders();
            //string variable to store any error message
            String Error = "";
            //create some test data to pass to the method
            string Description = "";

            Description = Description.PadRight(500, 'a');
            //invoke the method
            Error = AnOrder.Valid(CustomerId, ProductId, OrderDate, Description, Price, Status, DateShipped);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Ejemplo n.º 3
0
    protected void btnAccept_Click(object sender, EventArgs e)
    {
        clsOrders AnOrder          = new clsOrders();
        int       OrderId          = Convert.ToInt32(txtOrderId.Text);
        int       ItemId           = Convert.ToInt32(txtItemId.Text);
        DateTime  OrderDate        = Convert.ToDateTime(txtOrderDate.Text);
        string    DeliveryAddress  = txtDeliveryAddress.Text;
        Double    UnitPrice        = Convert.ToDouble(txtUnitPrice.Text);
        int       Quantity         = Convert.ToInt32(txtQuantity.Text);
        string    ProductCode      = txtProductCode.Text;
        bool      DispatchedStatus = chkDispatched.Checked;

        string Error = "";

        Error = AnOrder.Valid(OrderId, ItemId, OrderDate, DeliveryAddress, DispatchedStatus, UnitPrice, Quantity, ProductCode);

        if (Error == "")
        {
            AnOrder.OrderId          = OrderId;
            AnOrder.ItemId           = ItemId;
            AnOrder.OrderDate        = Convert.ToDateTime(OrderDate);
            AnOrder.DeliveryAddress  = DeliveryAddress;
            AnOrder.UnitPrice        = UnitPrice;
            AnOrder.Quantity         = Quantity;
            AnOrder.ProductCode      = ProductCode;
            AnOrder.DispatchedStatus = DispatchedStatus;

            clsOrderCollection OrdersList = new clsOrderCollection();

            if (OrderId == -1)
            {
                OrdersList.ThisOrder = AnOrder;
                OrdersList.Add();
            }
            else
            {
                OrdersList.ThisOrder.Find(OrderId);
                OrdersList.ThisOrder = AnOrder;
                OrdersList.Update();
            }

            Response.Redirect("OrdersList.aspx");
        }
        else
        {
            lblError.Text = Error;
        }
    }
Ejemplo n.º 4
0
        public void ThisOrderOK()
        {
            //create an instance
            clsOrdersCollection AllOrders = new clsOrdersCollection();
            //creating test data
            clsOrders TestOrder = new clsOrders();

            //set the properties
            TestOrder.Availability = true;
            TestOrder.OrderId      = 1;
            TestOrder.OrderDate    = DateTime.Now.Date;
            TestOrder.ShippingInfo = "test shipping";
            //assign te data
            AllOrders.ThisOrder = TestOrder;
            //test to see values are the same
            Assert.AreEqual(AllOrders.ThisOrder, TestOrder);
        }
Ejemplo n.º 5
0
        public void ThisOrdersOK()
        {
            clsOrderCollection AllOrders = new clsOrderCollection();

            clsOrders TestOrders = new clsOrders();

            TestOrders.OrderId          = 1;
            TestOrders.DeliveryAddress  = "An Address";
            TestOrders.DispatchedStatus = true;
            TestOrders.UnitPrice        = 5.99;
            TestOrders.Quantity         = 2;
            TestOrders.OrderDate        = DateTime.Now.Date;
            TestOrders.ProductCode      = "ABC1234";
            TestOrders.ItemId           = 1;

            AllOrders.ThisOrder = TestOrders;
            Assert.AreEqual(AllOrders.ThisOrder, TestOrders);
        }
Ejemplo n.º 6
0
        public void Payment_MethodMaxPlusOne()
        {
            //create an instance of the class we want to create
            clsOrders AnOrder = new clsOrders();
            //string variable to store any error messages
            String Error = "";
            //create some test data to pass to the method
            string Stock_ID             = "5678";
            string Expected_Return_Date = "26/01/2018";
            string Order_Date           = DateTime.Now.Date.ToString();
            string Customer_ID          = "123456";
            string Payment_Method       = "Cards";

            //invoke the method
            Error = AnOrder.Valid(Stock_ID, Expected_Return_Date, Order_Date, Customer_ID, Payment_Method);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
Ejemplo n.º 7
0
        public void OrderDateMin() //3
        {
            //create an instance of the class
            clsOrders AnOrder = new clsOrders();
            //string variable to store error messages
            String Error = "";
            //create a variable to store the test date data
            DateTime TestDate;

            //set the date to todays date
            TestDate = DateTime.Now.Date;
            //convert the date variable to a string variable
            string OrderDate = TestDate.ToString();

            //invoke the method
            Error = AnOrder.Valid(OrderDate, ShippingInfo);
            //test to see the result is correct
            Assert.AreEqual(Error, "");
        }
Ejemplo n.º 8
0
        public void Order_DateInvalidData()
        {
            //create an instance of the class we want to create
            clsOrders AnOrder = new clsOrders();
            //string variable to store any error messages
            String Error = "";
            //create some test data to pass to the method
            string Stock_ID             = "5678";
            string Expected_Return_Date = "26/01/2018";
            string Customer_ID          = "123456";
            string Payment_Method       = "Card";
            //set the order date to a non date value
            string Order_Date = "this is not a date";

            //invoke the method
            Error = AnOrder.Valid(Stock_ID, Expected_Return_Date, Order_Date, Customer_ID, Payment_Method);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Ejemplo n.º 9
0
        public void ThisOrderPropertyOK()
        {
            //create an instance of the class we want to create
            clsOrdersCollection AllOrders = new clsOrdersCollection();
            //create some test data to assign to the property
            clsOrders TestOrders = new clsOrders();

            //set the properties of the test object
            TestOrders.StockID            = "5678";
            TestOrders.CustomerID         = "123456";
            TestOrders.OrderNo            = "98765";
            TestOrders.PaymentMethod      = "Card";
            TestOrders.OrderDate          = DateTime.Now.Date;
            TestOrders.ExpectedReturnDate = DateTime.Now.Date.AddDays(7);
            //assign the data to the property
            AllOrders.ThisOrder = TestOrders;
            //test to see that the two values are the same
            Assert.AreEqual(AllOrders.ThisOrder, TestOrders);
        }
Ejemplo n.º 10
0
        public void ListAndCountOK()
        {
            clsOrderCollection AllOrders = new clsOrderCollection();
            List <clsOrders>   TestList  = new List <clsOrders>();

            clsOrders TestItem = new clsOrders();

            TestItem.OrderId          = 1;
            TestItem.DeliveryAddress  = "An Address";
            TestItem.DispatchedStatus = true;
            TestItem.UnitPrice        = 5.99;
            TestItem.Quantity         = 2;
            TestItem.OrderDate        = DateTime.Now.Date;
            TestItem.ProductCode      = "ABC1234";
            TestItem.ItemId           = 1;

            TestList.Add(TestItem);
            AllOrders.OrdersList = TestList;
            Assert.AreEqual(AllOrders.Count, TestList.Count);
        }
Ejemplo n.º 11
0
        public void AddMethodOK()
        {
            clsOrderCollection AllOrder = new clsOrderCollection();
            clsOrders          TestItem = new clsOrders();
            Int32 PrimaryKey            = 0;

            TestItem.OrderId          = 1;
            TestItem.DeliveryAddress  = "An Address";
            TestItem.DispatchedStatus = true;
            TestItem.UnitPrice        = 5.99;
            TestItem.Quantity         = 2;
            TestItem.OrderDate        = DateTime.Now.Date;
            TestItem.ProductCode      = "ABC1234";
            TestItem.ItemId           = 1;
            AllOrder.ThisOrder        = TestItem;
            PrimaryKey       = AllOrder.Add();
            TestItem.OrderId = PrimaryKey;
            AllOrder.ThisOrder.Find(PrimaryKey);
            Assert.AreEqual(AllOrder.ThisOrder, TestItem);
        }
Ejemplo n.º 12
0
        public void TestPaymentMethodFound()
        {
            //create an instance
            clsOrders AnOrder = new clsOrders();
            //boolean to store the result of the search
            Boolean Found = false;
            //boolean variable to record if the data is OK
            Boolean OK = true;
            //create some test data to use with the method
            string OrderNo = "98765";

            //invoke the method
            Found = AnOrder.Find(OrderNo);
            //check the property
            if (AnOrder.PaymentMethod != "Card")
            {
                OK = false;
            }
            //test to see the result is correct
            Assert.IsTrue(OK);
        }
Ejemplo n.º 13
0
        public void ListandCountOK()
        {
            //create an instance
            clsOrdersCollection AllOrders = new clsOrdersCollection();
            //create test data
            List <clsOrders> TestList = new List <clsOrders>();
            //add an item
            clsOrders TestItem = new clsOrders();

            //setting properties
            TestItem.Availability = true;
            TestItem.OrderId      = 1;
            TestItem.OrderDate    = DateTime.Now.Date;
            TestItem.ShippingInfo = "test shipping";
            //add the items to list
            TestList.Add(TestItem);
            //assign data to property
            AllOrders.OrderList = TestList;
            //test to see the values are the same
            Assert.AreEqual(AllOrders.Count, TestList.Count);
        }
Ejemplo n.º 14
0
        public void testOrderDateFound()
        {
            //create an instance
            clsOrders AnOrder = new clsOrders();
            //boolean to store the result of the search
            Boolean Found = false;
            //boolean variable to record if the data is OK
            Boolean OK = true;
            //create some test data to use with the method
            string OrderNo = "98765";

            //invoke the method
            Found = AnOrder.Find(OrderNo);
            //check the property
            if (AnOrder.OrderDate != Convert.ToDateTime("12/01/2018"))
            {
                OK = false;
            }
            //test to see the result is correct
            Assert.IsTrue(OK);
        }
Ejemplo n.º 15
0
        public void TestDateShippedFound()
        {
            //create an instance of the class that we want to create
            clsOrders AnOrder = new clsOrders();
            //boolean cariable to store the result of the search
            Boolean Found = false;
            //boolean variable recorded if data is OK (assume it is)
            Boolean OK = true;
            //create some test data to use with the method
            Int32 OrderId = 1;

            //invoke method
            Found = AnOrder.Find(OrderId);
            //check the property
            if (AnOrder.DateShipped != Convert.ToDateTime("14/03/2021"))
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
Ejemplo n.º 16
0
        public void TestStatusFound()
        {
            //create an instance of the class that we want to create
            clsOrders AnOrder = new clsOrders();
            //boolean variable to store the result of the search
            Boolean Found = false;
            //boolean variable recorded if data is OK (assume it is)
            Boolean OK = true;
            //create some test data to use with the method
            Int32 OrderId = 1;

            //invoke method
            Found = AnOrder.Find(OrderId);
            //check the property
            if (AnOrder.Status != "Dispatched")
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
Ejemplo n.º 17
0
        public void TestOrderIdFound()
        {
            //create an instance of the class
            clsOrders AnOrder = new clsOrders();
            //boolean variable to store the result of the search
            Boolean Found = false;
            //boolean variable to record if data is Ok (assuming it is)
            Boolean OK = true;
            //create some test data to use with the method
            Int32 OrderId = 1;

            //Invoke the method
            Found = AnOrder.Find(OrderId);
            //check the orderid
            if (AnOrder.OrderId != 1)
            {
                OK = false;
            }
            //test to see the result is correct
            Assert.IsTrue(OK);
        }
Ejemplo n.º 18
0
        public void TestCustomerIDFound()
        {
            //create an instance of the class we want to create
            clsOrders AnOrder = new clsOrders();
            //boolean variable to store the result of the search
            Boolean Found = false;
            //boolean variable to record if data is OK (assume it is)
            Boolean OK = true;
            //create some test data to use with the method
            string OrderNo = "98765";

            //invoke the method
            Found = AnOrder.Find(OrderNo);
            //check the customer id
            if (AnOrder.CustomerID != "123456")
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
Ejemplo n.º 19
0
        public void ThisOrderPropertyOK()
        {
            //create an instance of the class we want to create
            clsOrderCollection AllOrders = new clsOrderCollection();
            //create some test data to assign to the property
            clsOrders TestOrder = new clsOrders();

            //set the properties of the object
            TestOrder.OrderId     = 1;
            TestOrder.CustomerId  = 1;
            TestOrder.ProductId   = "23f";
            TestOrder.OrderDate   = DateTime.Now.Date;
            TestOrder.Description = "Description";
            TestOrder.Price       = 9.99;
            TestOrder.Paid        = true;
            TestOrder.Status      = "Shipped";
            TestOrder.DateShipped = DateTime.Now.Date;
            //assign the data to the property
            AllOrders.ThisOrder = TestOrder;
            //test to see that the two values are the same
            Assert.AreEqual(AllOrders.ThisOrder, TestOrder);
        }
Ejemplo n.º 20
0
    protected void btnFind_Click(object sender, EventArgs e)
    {
        //create an instance of the order class
        clsOrders AnOrder = new clsOrders();
        //variable to store the primary key
        Int32 OrderId;
        // variable to store the result of the find operation
        Boolean Found = false;

        //get the primary key entered by the user
        OrderId = Convert.ToInt32(txtOrderId.Text);
        //find the record
        Found = AnOrder.Find(OrderId);
        //if found
        if (Found == true)
        {
            //display the values of the properties in the form

            txtOrderDate.Text    = AnOrder.OrderDate.ToString();
            txtShippingInfo.Text = AnOrder.ShippingInfo;
        }
    }
Ejemplo n.º 21
0
    protected void btnFind_Click(object sender, EventArgs e)
    {
        clsOrders AnOrder = new clsOrders();
        Int32     OrderId;
        Boolean   Found = false;

        OrderId = Convert.ToInt32(txtOrderId.Text);
        Found   = AnOrder.Find(OrderId);
        if (Found == true)
        {
            txtItemId.Text          = Convert.ToString(AnOrder.ItemId);
            txtOrderDate.Text       = Convert.ToString(AnOrder.OrderDate);
            txtDeliveryAddress.Text = AnOrder.DeliveryAddress;
            txtUnitPrice.Text       = Convert.ToString(AnOrder.UnitPrice);
            txtQuantity.Text        = Convert.ToString(AnOrder.Quantity);
            txtProductCode.Text     = Convert.ToString(AnOrder.ProductCode);
            chkDispatched.Checked   = Convert.ToBoolean(AnOrder.DispatchedStatus);
        }
        else
        {
            lblError.Text = "Order ID not recognised";
        }
    }
Ejemplo n.º 22
0
        public void OrderListOK()
        {
            //create an instance of the class
            clsOrdersCollection AllOrders = new clsOrdersCollection();
            //create some test data to assign to the property
            //list of objects
            List <clsOrders> TestList = new List <clsOrders>();
            //add an item to the list
            //create item
            clsOrders TestItem = new clsOrders();

            //set properties
            TestItem.Availability = true;
            TestItem.OrderId      = 1;
            TestItem.OrderDate    = DateTime.Now.Date;
            TestItem.ShippingInfo = "test Shipping";
            //add item to test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllOrders.OrderList = TestList;
            //test to see the values are the same
            Assert.AreEqual(AllOrders.OrderList, TestList);
        }
Ejemplo n.º 23
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        //Create a new instance of clsOrders
        clsOrders Order = new clsOrders();

        //Capture the shipping address
        Order.ShippingAddress = txtShippingAddress.Text;
        //Capture the delivery date
        Order.DeliveryDate = DateTime.Parse(txtDeliveryDate.Text);
        //Capture the order placed
        //Order.OrderPlaced = Boolean.Parse(ChkOrderPlaced.Text);
        //Capture the orderLine checkout
        //Order.OrderLineCheckout = Boolean.Parse(ChkOrderLineCheckout.Text);
        //Capture the checkout date
        Order.CheckoutDate = DateTime.Parse(txtCheckoutDate.Text);
        //Capture the orderLine total
        Order.OrderLineTotal = int.Parse(txtOrderLineTotal.Text);
        //Capture the total cost
        Order.TotalCost = double.Parse(txtTotalCost.Text);
        //Store the shipping address in the session object
        Session["Order"] = Order;
        //Navigate to the viewer page
        Response.Redirect("OrdersViewer.aspx");
    }
Ejemplo n.º 24
0
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to create
            clsOrderCollection AllOrders = new clsOrderCollection();
            //create the test data
            clsOrders TestItem = new clsOrders();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set it's propertites
            TestItem.CustomerId  = 1;
            TestItem.ProductId   = "12c";
            TestItem.OrderDate   = DateTime.Now.Date;
            TestItem.Description = "Description 4";
            TestItem.Price       = 10.99;
            TestItem.Paid        = false;
            TestItem.Status      = "Needs Paying";
            TestItem.DateShipped = DateTime.Now.Date;
            //set ThisOrder to the test data
            AllOrders.ThisOrder = TestItem;
            //add the record
            PrimaryKey = AllOrders.Add();
            //set the primary key of the test data
            TestItem.OrderId = PrimaryKey;
            //modify the test data.
            TestItem.Paid   = true;
            TestItem.Status = "Dispatched";
            //set the record based on the new test data
            AllOrders.ThisOrder = TestItem;
            //update the record
            AllOrders.Update();
            //find the record
            AllOrders.ThisOrder.Find(PrimaryKey);
            //test to see ThisOrder matches the test data
            Assert.AreEqual(AllOrders.ThisOrder, TestItem);
        }
Ejemplo n.º 25
0
        public void InstanceOK()
        {
            clsOrders AnOrder = new clsOrders();

            Assert.IsNotNull(AnOrder);
        }
Ejemplo n.º 26
0
 internal async static Task <string> DeleteOrderAsync(clsOrders prOrder)
 {
     return(await InsertOrUpdateAsync(prOrder, "http://localhost:60064/api/phone/DeleteOrder", "DELETE"));
 }
Ejemplo n.º 27
0
 internal async static Task <string> ConfirmOrderAsync(clsOrders prOrder)
 {
     return(await InsertOrUpdateAsync(prOrder, "http://localhost:60064/api/phone/PutConfirmOrder", "PUT"));
 }
Ejemplo n.º 28
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //create a new instance of clsOrders
        clsOrders AnOrder = new clsOrders();
        //capture the Customer Id
        string CustomerId = txtCustomerId.Text;
        //capture the Product Id
        string ProductId = txtProductId.Text;
        //capture Order Date
        string OrderDate = txtOrderDate.Text;
        //capture the Description
        string Description = txtDescription.Text;
        //capture the Price
        string Price = txtPrice.Text;
        //capture the status
        string Status = txtStatus.Text;
        //capture Date Shipped
        string DateShipped = txtDateShipped.Text;
        //variabl to store any error messages
        string Error = "";

        //validate the data
        Error = AnOrder.Valid(CustomerId, ProductId, OrderDate, Description, Price, Status, DateShipped);
        if (Error == "")
        {
            //capture the OrderId
            AnOrder.OrderId = OrderId;
            //capture the Customer Id
            AnOrder.CustomerId = Convert.ToInt32(CustomerId);
            //capture the Product Id
            AnOrder.ProductId = ProductId;
            //capture the Order Date
            AnOrder.OrderDate = Convert.ToDateTime(OrderDate);
            //capture the Description
            AnOrder.Description = Description;
            //capture the Price
            AnOrder.Price = Convert.ToDouble(Price);
            //capture Paid
            AnOrder.Paid = ChkPaid.Checked;
            //capture the Status
            AnOrder.Status = Status;
            //capture the Date Shipped
            AnOrder.DateShipped = Convert.ToDateTime(DateShipped);
            //create a new instance of the order collection
            clsOrderCollection OrderList = new clsOrderCollection();
            //if this is a new record i.e. OrderId = -1 then add the data
            if (OrderId == -1)
            {
                //set the ThisOrder property
                OrderList.ThisOrder = AnOrder;
                //add the new record
                OrderList.Add();
            }
            //otherwise it must be an update
            else
            {
                //find the record to update
                OrderList.ThisOrder.Find(OrderId);
                //set the ThisOrder property
                OrderList.ThisOrder = AnOrder;
                //update the record
                OrderList.Update();
            }
            //redirect back to the list page
            Response.Redirect("OrdersList.aspx");
        }
        else
        {
            //display the error message
            lblError.Text = Error;
        }
    }