Exemplo n.º 1
0
        public void AddMethodOK()
        {
            //creates an instance of class we want to create
            ClsOrderCollection AllOrder = new ClsOrderCollection();
            //creates item of test data
            ClsOrder TestItem = new ClsOrder();
            //Var to store primary key
            Int32 PrimaryKey = 0;

            //Sets its properties
            TestItem.OrderID         = 1;
            TestItem.CustomerID      = 45879632;
            TestItem.ShippingAddress = "64 potter Lane";
            TestItem.OrderStatus     = "Pending";
            TestItem.OrderDate       = DateTime.Now.Date;
            TestItem.OrderShipped    = false;
            //set ThisOrder to the test data
            AllOrder.ThisOrder = TestItem;
            //add the record
            PrimaryKey = AllOrder.Add();
            //set primary key of the test data
            TestItem.OrderID = PrimaryKey;
            //find the record
            AllOrder.ThisOrder.Find(PrimaryKey);
            //Test to see if the two are the same
            Assert.AreEqual(AllOrder.ThisOrder, TestItem);
        }
Exemplo n.º 2
0
        public void DeleteMethodOK()
        {
            //creates instance of class we want to create
            ClsOrderCollection AllOrder = new ClsOrderCollection();
            //creates the item of test data
            ClsOrder TestItem = new ClsOrder();
            //Var to store primary key
            Int32 PrimaryKey = 0;

            //Sets its properties
            TestItem.OrderID         = 1;
            TestItem.CustomerID      = 45879632;
            TestItem.ShippingAddress = "64 potter Lane";
            TestItem.OrderStatus     = "pending";
            TestItem.OrderDate       = DateTime.Now.Date;
            TestItem.OrderShipped    = false;
            //set ThisOrder to the test data
            AllOrder.ThisOrder = TestItem;
            //add the record
            PrimaryKey = AllOrder.Add();
            //set primary key of the test data
            TestItem.OrderID = PrimaryKey;
            //find the record
            AllOrder.ThisOrder.Find(PrimaryKey);
            //delete the record
            AllOrder.Delete();
            //now find the record
            Boolean Found = AllOrder.ThisOrder.Find(PrimaryKey);

            //Test to see if the record was not found
            Assert.IsTrue(Found);
        }
Exemplo n.º 3
0
        public void ListAndCountOK()
        {
            //creates an instance of class we want to create
            ClsOrderCollection AllOrder = new ClsOrderCollection();
            //Test data to assign to property
            List <ClsOrder> TestList = new List <ClsOrder>();
            //creates item of test data
            ClsOrder TestItem = new ClsOrder();

            //Set properties
            TestItem.OrderID         = 1;
            TestItem.CustomerID      = 45879632;
            TestItem.ShippingAddress = "64 potter Lane";
            TestItem.OrderStatus     = "Pending";
            TestItem.OrderDate       = DateTime.Now.Date;
            TestItem.OrderShipped    = false;
            //Add item to test list
            TestList.Add(TestItem);
            //reinitialise the object for some new data
            TestItem = new ClsOrder();
            //sets its properties
            TestItem.OrderID         = 2;
            TestItem.CustomerID      = 58974136;
            TestItem.ShippingAddress = "54 Queensville";
            TestItem.OrderStatus     = "Dispatched";
            TestItem.OrderDate       = DateTime.Now.Date;
            TestItem.OrderShipped    = true;
            //Add item to test list
            TestList.Add(TestItem);
            //Assign data to the property
            AllOrder.OrderList = TestList;
            //Test to see if the two are the same
            Assert.AreEqual(AllOrder.Count, TestList.Count);
        }
Exemplo n.º 4
0
    protected void BtnApply_Click(object sender, EventArgs e)
    {
        if (txtOrderStatus.Text == "")
        {
            lblError.Text = "Please enter an Order status before trying to filter";
        }
        else
        {
            //lblError.Text = "";
            ClsOrderCollection Orders = new ClsOrderCollection();
            Orders.ReportByOrderStatus(txtOrderStatus.Text);
            lstOrderList.DataSource     = Orders.OrderList;
            lstOrderList.DataValueField = "OrderID";
            lstOrderList.DataTextField  = "allProperties";
            lstOrderList.DataBind();

            if (lstOrderList.Items.Count > 0)
            {
                lblError.Text = "";
            }
            else if (lstOrderList.Items.Count == 0)
            {
                lblError.Text = "There are no records with the status " + txtOrderStatus.Text + " please try again";
                Orders.ReportByOrderStatus("");
                txtOrderStatus.Text = "";
                DisplayOrders();
            }
        }
    }
Exemplo n.º 5
0
    protected void BtnApply2_Click(object sender, EventArgs e)
    {
        lblError.Text = "";
        ClsOrderCollection Orders  = new ClsOrderCollection();
        string             orderID = txtOrderID.Text;
        int  OID  = 0;
        bool canC = int.TryParse(orderID, out OID);

        if (canC == false)
        {
            lblError.Text = "Please enter a valid OrderID";
        }
        else
        {
            Orders.ReportByOrderID(Convert.ToInt32(txtOrderID.Text));
        }

        lstOrderList.DataSource     = Orders.OrderList;
        lstOrderList.DataValueField = "OrderID";
        lstOrderList.DataTextField  = "allProperties";
        lstOrderList.DataBind();

        if (lstOrderList.Items.Count <= 0)
        {
            lblError.Text = "There are no records with the OrderID: " + txtOrderID.Text;
        }
    }
        public void UpdateMethodOK()
        {
            ClsOrderCollection AllOrders = new ClsOrderCollection();
            ClsOrder           AnOrder   = new ClsOrder();
            int PrimaryKey = 0;

            AnOrder.CustomerID  = 2;
            AnOrder.CarID       = 2;
            AnOrder.DateOfOrder = DateTime.Now.Date;
            AnOrder.ServiceID   = 66;
            AnOrder.OrderPrice  = 50000;
            AnOrder.OrderStatus = "pending";
            AnOrder.PaymentID   = 3;
            AnOrder.Completed   = false;

            AllOrders.ThisOrder = AnOrder;
            PrimaryKey          = AllOrders.Add();
            AnOrder.OrderID     = PrimaryKey;

            AnOrder.CustomerID  = 2;
            AnOrder.CarID       = 2;
            AnOrder.DateOfOrder = DateTime.Now.Date;
            AnOrder.ServiceID   = 66;
            AnOrder.OrderPrice  = 50000;
            AnOrder.OrderStatus = "completed";
            AnOrder.PaymentID   = 3;
            AnOrder.Completed   = true;

            AllOrders.ThisOrder = AnOrder;
            AllOrders.Update();
            AllOrders.ThisOrder.Find(PrimaryKey);
            Assert.AreEqual(AllOrders.ThisOrder, AnOrder);
            AllOrders.Delete();
        }
        public void ReportByOrderStatusNoneFound()
        {
            ClsOrderCollection FilteredOrders = new ClsOrderCollection();

            FilteredOrders.ReportByOrderStatus("XXX");
            Assert.AreEqual(0, FilteredOrders.Count);
        }
Exemplo n.º 8
0
        public void ReportByShippingAddressTestDataFound()
        {
            //creates an instance of the filtered data
            ClsOrderCollection FilteredOrder = new ClsOrderCollection();
            //var to store outcome
            Boolean OK = true;

            //apply a Shipping Address which does not exist
            FilteredOrder.ReportByShippingAddress("xx xxxx xxxxxx");
            //check if that is the correct number of records that are found
            if (FilteredOrder.Count == 2)
            {
                //checks the first record is OrderID 4
                if (FilteredOrder.OrderList[0].OrderID != 4)
                {
                    OK = false;
                }
                //checks the first record is OrderID 5
                if (FilteredOrder.OrderList[0].OrderID != 4)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }

            //tests to see that there are no records
            Assert.IsFalse(OK);
        }
Exemplo n.º 9
0
    protected void BtnClear2_Click(object sender, EventArgs e)
    {
        ClsOrderCollection Orders = new ClsOrderCollection();

        txtOrderID.Text = "";
        DisplayOrders();
        lblError.Text = "";
    }
Exemplo n.º 10
0
        public void CountPropertyOK()
        {
            ClsOrderCollection AllOrder = new ClsOrderCollection();
            Int32 SomeCount             = 15;

            AllOrder.Count = SomeCount;
            Assert.AreEqual(AllOrder.Count, SomeCount);
        }
Exemplo n.º 11
0
    protected void btnYes_Click(object sender, EventArgs e)
    {
        ClsOrderCollection Orders = new ClsOrderCollection();

        Orders.ThisOrder.Find(OrderID);
        Orders.Delete();
        Response.Redirect("OrderList.aspx");
    }
Exemplo n.º 12
0
    protected void BtnClear_Click(object sender, EventArgs e)
    {
        ClsOrderCollection Orders = new ClsOrderCollection();

        Orders.ReportByOrderStatus("");
        txtOrderStatus.Text = "";
        DisplayOrders();
        lblError.Text = "";
    }
Exemplo n.º 13
0
        public void ReportByOrderStatusMethodOK()
        {
            ClsOrderCollection AllOrders = new ClsOrderCollection();
            //ClsOrder AnOrder = new ClsOrder();
            ClsOrderCollection FilteredOrders = new ClsOrderCollection();

            FilteredOrders.ReportByOrderStatus("");
            Assert.AreEqual(AllOrders.Count, FilteredOrders.Count);
        }
Exemplo n.º 14
0
        public void ReportByShippingAddressNoneFound()
        {
            //creates an instance of the filtered data
            ClsOrderCollection FilteredOrder = new ClsOrderCollection();

            //applies the Shipping Address that does not exist
            FilteredOrder.ReportByShippingAddress("xx xxxx xxxxxx");
            //tests to see that there are no records
            Assert.AreEqual(0, FilteredOrder.Count);
        }
Exemplo n.º 15
0
    protected void BtnYes_Click(object sender, EventArgs e)
    {
        //create an instance of the Order Collection
        ClsOrderCollection OrderList = new ClsOrderCollection();

        //finds the record to delete
        OrderList.ThisOrder.Find(OrderID);
        //deletes the record
        OrderList.Delete();
        //Redirects back to the main page
        Response.Redirect("OrderList.aspx");
    }
Exemplo n.º 16
0
        public void ReportByShippingAddressMethodOK()
        {
            //creates an instance of class we want to create
            ClsOrderCollection AllOrder = new ClsOrderCollection();
            //creates an instance of the filtered data
            ClsOrderCollection FilteredOrder = new ClsOrderCollection();

            //applies a blank string (should return all the redords);
            FilteredOrder.ReportByShippingAddress("");
            //tests to see of the two values are the same
            Assert.AreEqual(AllOrder.Count, FilteredOrder.Count);
        }
Exemplo n.º 17
0
    void DisplayOrder()
    {
        //create an instance of the Order collection
        ClsOrderCollection OrderCollection = new ClsOrderCollection();

        //find the record to update
        OrderCollection.ThisOrder.Find(OrderID);
        //display the data for this record
        txtOrderID.Text         = OrderCollection.ThisOrder.OrderID.ToString();
        txtOrderDate.Text       = OrderCollection.ThisOrder.OrderDate.ToString();
        txtCustomerID.Text      = OrderCollection.ThisOrder.CustomerID.ToString();
        txtShippingAddress.Text = OrderCollection.ThisOrder.ShippingAddress;
    }
Exemplo n.º 18
0
    void DisplayOrder()
    {
        //create an instance of the Order Collection
        ClsOrderCollection Orders = new ClsOrderCollection();

        //set the data source to the list of Orders in the collection
        lstOrderList.DataSource = Orders.OrderList;
        //set the name of the primary key
        lstOrderList.DataValueField = "OrderID";
        //set the data field to display
        lstOrderList.DataTextField = "OrderStatus";
        //bind the data to the list
        lstOrderList.DataBind();
    }
Exemplo n.º 19
0
        public void ThisOrderPropertyOK()
        {
            ClsOrderCollection AllOrders = new ClsOrderCollection();
            ClsOrder           TestItem  = new ClsOrder();

            TestItem.CustomerID  = 2;
            TestItem.CarID       = 2;
            TestItem.DateOfOrder = DateTime.Now.Date;
            TestItem.ServiceID   = 1;
            TestItem.OrderPrice  = 5000;
            TestItem.OrderStatus = "Done";
            TestItem.PaymentID   = 1;
            TestItem.Completed   = true;
            AllOrders.ThisOrder  = TestItem;
            Assert.AreEqual(AllOrders.ThisOrder, TestItem);
        }
Exemplo n.º 20
0
    void DisplayOrders()
    {
        ClsOrderCollection Orders = new ClsOrderCollection();

        Orders.ThisOrder.Find(OrderID);

        TxtOrderID.Text                = Orders.ThisOrder.OrderID.ToString();
        txtCustomerID.Text             = Orders.ThisOrder.CustomerID.ToString();
        DropDownCars.SelectedValue     = Orders.ThisOrder.CarID.ToString();
        TxtPaymentID.Text              = Orders.ThisOrder.PaymentID.ToString();
        DropDownServices.SelectedValue = Orders.ThisOrder.ServiceID.ToString();
        TxtDateOfOrder.Text            = Orders.ThisOrder.DateOfOrder.ToString();
        txtPrice.Text             = Orders.ThisOrder.OrderPrice.ToString();
        txtOrderStatus.Text       = Orders.ThisOrder.OrderStatus;
        CheckBoxCompleted.Checked = Orders.ThisOrder.Completed;
    }
Exemplo n.º 21
0
    protected void BtnApply_Click(object sender, EventArgs e)
    {
        //create an instance of the customer collection
        ClsOrderCollection OrderCollection = new ClsOrderCollection();

        OrderCollection.ReportByShippingAddress(txtFilter.Text);
        //clear any existing filter to tidy up the interface
        txtFilter.Text          = "";
        lstOrderList.DataSource = OrderCollection.OrderList;
        //set the name of the primary key
        lstOrderList.DataValueField = "OrderID";
        //set the name of the field to display
        lstOrderList.DataTextField = "ShippingAddress";
        //bind the data to the list
        lstOrderList.DataBind();
    }
Exemplo n.º 22
0
        public void OrderListOK()
        {
            ClsOrderCollection AllOrder = new ClsOrderCollection();
            List <ClsOrder>    TestList = new List <ClsOrder>();
            ClsOrder           TestItem = new ClsOrder();

            TestItem.OrderID         = 1;
            TestItem.CustomerID      = 45879632;
            TestItem.ShippingAddress = "64 potter Lane";
            TestItem.OrderStatus     = "Pending";
            TestItem.OrderDate       = DateTime.Now.Date;
            TestItem.OrderShipped    = false;
            TestList.Add(TestItem);
            AllOrder.OrderList = TestList;
            Assert.AreEqual(AllOrder.OrderList, TestList);
        }
Exemplo n.º 23
0
        public void ListAndCountOK()
        {
            ClsOrderCollection AllOrders = new ClsOrderCollection();
            List <ClsOrder>    TestList  = new List <ClsOrder>();
            ClsOrder           TestItem  = new ClsOrder();

            TestItem.CustomerID  = 2;
            TestItem.CarID       = 2;
            TestItem.DateOfOrder = DateTime.Now.Date;
            TestItem.ServiceID   = 66;
            TestItem.OrderPrice  = 5000;
            TestItem.OrderStatus = "test";
            TestItem.PaymentID   = 1;
            TestItem.Completed   = true;
            TestList.Add(TestItem);
            AllOrders.OrderList = TestList;
            Assert.AreEqual(AllOrders.Count, TestList.Count);
        }
Exemplo n.º 24
0
        public void ThisOrderPropertyOK()
        {
            ClsOrderCollection AllOrder = new ClsOrderCollection();
            //Test data to assign to property
            ClsOrder TestOrder = new ClsOrder();

            //Set properties of the test item
            TestOrder.OrderID         = 1;
            TestOrder.CustomerID      = 45879632;
            TestOrder.ShippingAddress = "64 potter Lane";
            TestOrder.OrderStatus     = "Pending";
            TestOrder.OrderDate       = DateTime.Now.Date;
            TestOrder.OrderShipped    = false;
            //Assign data to the property
            AllOrder.ThisOrder = TestOrder;
            //Test to see that the two are the same
            Assert.AreEqual(AllOrder.ThisOrder, TestOrder);
        }
Exemplo n.º 25
0
        public void AddMethodOK()
        {
            ClsOrderCollection AllOrders = new ClsOrderCollection();
            ClsOrder           AnOrder   = new ClsOrder();
            int PrimaryKey = 0;

            AnOrder.CustomerID  = 2;
            AnOrder.CarID       = 2;
            AnOrder.DateOfOrder = DateTime.Now.Date;
            AnOrder.ServiceID   = 66;
            AnOrder.OrderPrice  = 5000;
            AnOrder.OrderStatus = "test";
            AnOrder.PaymentID   = 3;
            AnOrder.Completed   = true;
            AllOrders.ThisOrder = AnOrder;
            PrimaryKey          = AllOrders.Add();
            AnOrder.OrderID     = PrimaryKey;
            AllOrders.ThisOrder.Find(PrimaryKey);
            Assert.AreEqual(AllOrders.ThisOrder, AnOrder);
            AllOrders.Delete(); // This to delete the new record we have just made for consistancey with the rest of the test.
        }
Exemplo n.º 26
0
        public void UpdateMethodOK()
        {
            //creates an instance of class we want to create
            ClsOrderCollection AllOrder = new ClsOrderCollection();
            //creates item of test data
            ClsOrder TestItem = new ClsOrder();
            //Var to store primary key
            Int32 PrimaryKey = 0;

            //Sets its properties
            TestItem.OrderID         = 1;
            TestItem.CustomerID      = 45879632;
            TestItem.ShippingAddress = "64 potter Lane";
            TestItem.OrderStatus     = "Pending";
            TestItem.OrderDate       = DateTime.Now.Date;
            TestItem.OrderShipped    = false;
            //set ThisOrder to the test data
            AllOrder.ThisOrder = TestItem;
            //add the record
            PrimaryKey = AllOrder.Add();
            //set primary key of the test data
            TestItem.OrderID = PrimaryKey;
            //modify test data
            TestItem.OrderID         = 2;
            TestItem.CustomerID      = 58974136;
            TestItem.ShippingAddress = "54 Queensville";
            TestItem.OrderStatus     = "Dispatched";
            TestItem.OrderDate       = DateTime.Now.Date;
            TestItem.OrderShipped    = true;
            //sets the record based on new data
            AllOrder.ThisOrder = TestItem;
            //updates record
            AllOrder.Update();
            //find record
            AllOrder.ThisOrder.Find(PrimaryKey);
            //tests to see if ThisOrder matches test data
            Assert.AreEqual(AllOrder.ThisOrder, TestItem);
        }
Exemplo n.º 27
0
        public void DeleteMethodOK()
        {
            ClsOrderCollection AllOrders = new ClsOrderCollection();
            ClsOrder           AnOrder   = new ClsOrder();
            int PrimaryKey = 0;

            AnOrder.CustomerID  = 2;
            AnOrder.CarID       = 2;
            AnOrder.DateOfOrder = DateTime.Now.Date;
            AnOrder.ServiceID   = 66;
            AnOrder.OrderPrice  = 50000;
            AnOrder.OrderStatus = "Done";
            AnOrder.PaymentID   = 3;
            AnOrder.Completed   = true;
            AllOrders.ThisOrder = AnOrder;
            PrimaryKey          = AllOrders.Add();
            AnOrder.OrderID     = PrimaryKey;
            AllOrders.ThisOrder.Find(PrimaryKey);
            AllOrders.Delete();
            bool Found = AllOrders.ThisOrder.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
Exemplo n.º 28
0
        public void ReportByOrderStatusTestDataFound()
        {
            ClsOrderCollection FilteredOrders = new ClsOrderCollection();
            Boolean            OK             = true;

            FilteredOrders.ReportByOrderStatus("completed");
            if (FilteredOrders.Count == 8)
            {
                if (FilteredOrders.OrderList[0].OrderID != 51)
                {
                    OK = false;
                }
                if (FilteredOrders.OrderList[1].OrderID != 52)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            Console.Write(FilteredOrders.Count);
            Assert.IsTrue(OK);
        }
Exemplo n.º 29
0
    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;
        }
    }
Exemplo n.º 30
0
        public void InstanceOK()
        {
            ClsOrderCollection AllOrders = new ClsOrderCollection();

            Assert.IsNotNull(AllOrders);
        }