Exemplo n.º 1
0
        public void ReportByMethodTestDataFound()
        {
            //create an instance of the filtered data
            clsOrderCollection FilteredItemType = new clsOrderCollection();
            //var to store outcomes
            Boolean OK = true;

            //apply a Item type that doesn't exist
            FilteredItemType.ReportByItemType("121321313212132132131321");
            //check that the correct number of records are found
            if (FilteredItemType.Count == 2)
            {
                //check that the first record is id 2
                if (FilteredItemType.OrderList[0].OrderID != 9)
                {
                    OK = false;
                }
                //check that the first record is id 1
                if (FilteredItemType.OrderList[1].OrderID != 10)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            //test to see that there are no records
            Assert.IsFalse(OK);
        }
Exemplo n.º 2
0
        public void OrderListOK()
        {
            //create an instance of the class we want to create
            clsOrderCollection AllOrder = new clsOrderCollection();
            //create some test data to assign to the property
            List <clsOrder> TestList = new List <clsOrder>();
            //add an item to the list
            //create the item of test data
            clsOrder TestItem = new clsOrder();

            //set its properties
            TestItem.Quality  = true;
            TestItem.OrderID  = 3;
            TestItem.ItemName = "BMW";
            TestItem.Date     = "21/03/2008";
            TestItem.ItemType = "Car";
            TestItem.Price    = 44737;
            TestItem.Quantity = 1;
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllOrder.OrderList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllOrder.OrderList, TestList);
        }
Exemplo n.º 3
0
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsOrderCollection AllOrder = new clsOrderCollection();
            //create the item of test data
            clsOrder TestItem = new clsOrder();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.Quality  = true;
            TestItem.OrderID  = 3;
            TestItem.ItemName = "BMW";
            TestItem.Date     = "21/03/2008";
            TestItem.ItemType = "Car";
            TestItem.Price    = 44737;
            TestItem.Quantity = 1;
            //set ThisOrder to the test data
            AllOrder.ThisOrder = TestItem;
            //add the record
            PrimaryKey = AllOrder.Add();
            //set the primary key of the test data
            TestItem.OrderID = PrimaryKey;
            //find the record
            AllOrder.ThisOrder.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllOrder.ThisOrder, TestItem);
        }
Exemplo n.º 4
0
        public void DeleteMethodOK()
        {
            //create an instance of the class we want to create
            clsOrderCollection AllOrder = new clsOrderCollection();
            //create the item of the test data
            clsOrder TestItem = new clsOrder();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.Quality  = true;
            TestItem.OrderID  = 3;
            TestItem.ItemName = "BMW";
            TestItem.Date     = "21/03/2008";
            TestItem.ItemType = "Car";
            TestItem.Price    = 44737;
            TestItem.Quantity = 1;
            //set ThisOrder to the test data
            AllOrder.ThisOrder = TestItem;
            //add the record
            PrimaryKey = AllOrder.Add();
            //set the 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 that the record was not found
            Assert.IsFalse(Found);
        }
Exemplo n.º 5
0
        public void AddOK()
        {
            //create an instance of the class
            clsOrderCollection AllOrders = new clsOrderCollection();
            //create some test data for the class
            clsOrder TestItem = new clsOrder();
            //create var to store the property
            Int32 PrimaryKey = 0;

            //set the properties
            TestItem.Address      = "some address";
            TestItem.CustomerId   = 1;
            TestItem.DateDispatch = DateTime.Now.Date;
            TestItem.ItemName     = "some name";
            TestItem.ItemQuantity = 4;
            TestItem.OrderId      = 3;
            TestItem.Made         = true;
            //set the test data properties to the ThisOrder
            AllOrders.ThisOrder = TestItem;
            //add the record
            PrimaryKey = AllOrders.Add();
            //set the primary key of the test data
            TestItem.OrderId = PrimaryKey;
            //find the record
            AllOrders.ThisOrder.Find(PrimaryKey);
            //check to see if both are the same
            Assert.AreEqual(AllOrders.ThisOrder, TestItem);
        }
Exemplo n.º 6
0
        public void ReportByItemNameFound()
        {
            //create an instance of the filtered data
            clsOrderCollection FilteredOrders = new clsOrderCollection();
            //var to store outcome
            Boolean OK = true;

            //apply an item name that doesn't exist
            FilteredOrders.ReportByItemName("Falcon");
            if (FilteredOrders.Count == 2)
            {
                //check the first record is ID 41
                if (FilteredOrders.OrderList[0].OrderId != 41)
                {
                    OK = false;
                }
                //check the second record is ID 42
                if (FilteredOrders.OrderList[1].OrderId != 42)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            //test to see that there are no records
            Assert.IsTrue(OK);
        }
Exemplo n.º 7
0
        public void DeleteMethodOK()
        {
            //create an instance of the class
            clsOrderCollection AllOrders = new clsOrderCollection();
            //create the item of test data
            clsOrder TestItem = new clsOrder();
            //var to store primary key
            Int32 PrimaryKey = 0;

            //set the properties
            TestItem.Address      = "some address";
            TestItem.CustomerId   = 2;
            TestItem.DateDispatch = DateTime.Now.Date;
            TestItem.ItemName     = "Zack Snyder's cut";
            TestItem.ItemQuantity = 2;
            TestItem.Made         = true;
            TestItem.OrderId      = 5;
            //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;
            //find the record
            AllOrders.ThisOrder.Find(PrimaryKey);
            //delete the record
            AllOrders.Delete();
            //now find the record
            Boolean Found = AllOrders.ThisOrder.Find(PrimaryKey);

            //test to see if the order was not found
            Assert.IsFalse(Found);
        }
Exemplo n.º 8
0
        public void OrderListOK()
        {
            // create an instance of the class we want to create
            clsOrderCollection AllOrders = new clsOrderCollection();
            // create some test data to assign to the property
            // in this case the data needs to be a list of objects
            List <clsOrder> TestList = new List <clsOrder>();
            // add an item to the list
            // create the item of test data
            clsOrder TestItem = new clsOrder();

            // set its properties
            TestItem.OrderNo      = 2;
            TestItem.FirstChoice  = 3;
            TestItem.SecondChoice = 2;
            TestItem.ThirdChoice  = 1;
            TestItem.FirstPrice   = 3;
            TestItem.SecondPrice  = 2;
            TestItem.ThirdPrice   = 1;
            TestItem.OrderTotal   = 6;
            // add the item to the list
            TestList.Add(TestItem);
            // assign the data to the property
            AllOrders.OrderList = TestList;
            // test to see that the two values are the same
            Assert.AreEqual(AllOrders.OrderList, TestList);
        }
Exemplo n.º 9
0
        public void DeleteMethodOK()
        {
            //create an instance of the class
            clsOrderCollection AllOrders = new clsOrderCollection();
            //create some test data to assign to the property
            clsOrder TestItem = new clsOrder();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            // set its properties
            TestItem.OrderNo      = 1;
            TestItem.FirstChoice  = 3;
            TestItem.SecondChoice = 2;
            TestItem.ThirdChoice  = 1;
            TestItem.FirstPrice   = 1;
            TestItem.SecondPrice  = 3;
            TestItem.ThirdPrice   = 4;
            TestItem.OrderTotal   = 8;
            // set this order to the test data
            AllOrders.ThisOrder = TestItem;
            // add the record
            PrimaryKey = AllOrders.Add();
            // set the primary key of the test data
            TestItem.OrderNo = PrimaryKey;
            // find the record
            AllOrders.ThisOrder.Find(PrimaryKey);
            // delete the record
            AllOrders.Delete();
            // now find the record
            Boolean Found = AllOrders.ThisOrder.Find(PrimaryKey);

            // test to see that the two values are the same
            Assert.IsFalse(Found);
        }
Exemplo n.º 10
0
    void Update()
    {
        //create an instance of the Orderlog
        clsOrderCollection OrderLog = new clsOrderCollection();
        //validate the date on the web form
        String Error = OrderLog.ThisOrder.Valid(txtItemName.Text, txtQuantity.Text, txtDate.Text, txtPrice.Text);

        //if the data is OK then add it to the object
        if (Error == "")
        {
            //find the record to update
            OrderLog.ThisOrder.Find(OrderID);
            // recieve data from the user
            OrderLog.ThisOrder.ItemName = txtItemName.Text;
            OrderLog.ThisOrder.Quantity = Convert.ToInt32(txtQuantity.Text);
            OrderLog.ThisOrder.Price    = Convert.ToInt32(txtPrice.Text);
            OrderLog.ThisOrder.Date     = txtDate.Text;
            OrderLog.ThisOrder.Quality  = chkNew.Checked = true;
            OrderLog.ThisOrder.ItemType = ddlItemType.Text;
            //update the record
            OrderLog.Update();
            //redirect back to the main page
            Response.Redirect("Order.aspx");
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the data entry" + Error;
        }
    }
Exemplo n.º 11
0
        public void DeleteMethodOK()
        {
            //Create an instance of the class we want to create
            clsOrderCollection AllOrders = new clsOrderCollection();
            //Create the item of test data
            clsOrder TestItem = new clsOrder();
            //Var to store the primary key
            Int32 PrimaryKey = 0;

            //Set its properties
            TestItem.Delivery        = true;
            TestItem.DateAdded       = DateTime.Now.Date;
            TestItem.ShippingAddress = "18 Lala St";
            TestItem.Description     = "FILA";
            TestItem.OrderQuantity   = 1;
            //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;
            //Find the record
            AllOrders.ThisOrder.Find(PrimaryKey);
            //Delete the record
            AllOrders.Delete();
            //Now find the record
            Boolean Found = AllOrders.ThisOrder.Find(PrimaryKey);

            //Test to see that the record was not found
            Assert.IsFalse(Found);
        }
Exemplo n.º 12
0
    Int32 DisplayOrder(string ItemTypeFilter)
    {
        Int32              OrderID;  //var to store the primary key
        string             ItemName; //var to store the item name
        string             ItemType; // var to store the ItemType
        clsOrderCollection MyOrderCollection = new clsOrderCollection();

        //create an instance of the Order collection class
        MyOrderCollection.ReportByItemType(ItemTypeFilter);
        //create an instance of the Order collection class
        Int32 RecordCount;                                          //var to store the count of records
        Int32 Index = 0;                                            //var to store the index for the loop

        RecordCount = MyOrderCollection.Count;                      //get the count of records
        lstOrder.Items.Clear();                                     //clear the list box
        while (Index < RecordCount)                                 //while there are records to process
        {
            OrderID  = MyOrderCollection.OrderList[Index].OrderID;  //get the primary key
            ItemName = MyOrderCollection.OrderList[Index].ItemName; // get the ItemName
            ItemType = MyOrderCollection.OrderList[Index].ItemType; //get the ItemType
            //create a new entry for the list box
            ListItem NewEntry = new ListItem(ItemName + "  ,   " + ItemType, OrderID.ToString());
            lstOrder.Items.Add(NewEntry); //add the Order to the list
            Index++;                      //move the index to the next record
        }
        return(RecordCount);              // return the count of records found
    }
Exemplo n.º 13
0
        void Add()
        {
            //create an instance of the Order Collenction
            clsOrderCollection AllOrders = new clsOrderCollection();
            //validate the data on the web form
            string Error = AllOrders.ThisOrder.Valid(txtEmail.Text, txtTotalPrice.Text, txtDateOrdered.Text, txtShippingAddress.Text, txtPhonenum.Text);

            //if the data is OK then add it to the object
            if (Error == "")
            {
                //get the data entered by the user
                AllOrders.ThisOrder.Email           = txtEmail.Text;
                AllOrders.ThisOrder.TotalPrice      = Convert.ToDecimal(txtTotalPrice.Text);
                AllOrders.ThisOrder.DateOrdered     = Convert.ToDateTime(txtDateOrdered.Text);
                AllOrders.ThisOrder.ShippingAddress = Convert.ToString(txtShippingAddress.Text);
                AllOrders.ThisOrder.Phonenum        = txtPhonenum.Text;

                //add the record
                AllOrders.Add();
                //all done so redirect back to the main page
                OrderManageForm OM = new OrderManageForm();
                this.Hide();
                OM.ShowDialog();
                this.Close();
            }
            else
            {
                //report an error
                lblError.Text = "There were problems with the data entered : " + Error;
            }
        }
Exemplo n.º 14
0
        public void ListAndCountOK()
        {
            //Create an instance of the class we want to create
            clsOrderCollection AllOrders = new clsOrderCollection();
            //Create some test data to assign to the property
            //In this case the data needs to be a list of objects
            List <clsOrder> TestList = new List <clsOrder>();
            //Add an item to the list
            //Create the item of test data
            clsOrder TestItem = new clsOrder();

            //Set its properties
            TestItem.OrderId         = 1;
            TestItem.DateAdded       = DateTime.Now.Date;
            TestItem.ShippingAddress = "22 New Park St";
            TestItem.Delivery        = true;
            TestItem.Description     = "ADIDAS";
            TestItem.OrderQuantity   = 1;
            //Add the item to the test list
            TestList.Add(TestItem);
            //Assign the data to the property
            AllOrders.OrderList = TestList;
            //Test to see that the two values are the same
            Assert.AreEqual(AllOrders.Count, TestList.Count);
        }
Exemplo n.º 15
0
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsOrderCollection AllOrders = new clsOrderCollection();
            //create the item of test data
            clsOrder TestItem = new clsOrder();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.OrderID     = 1;
            TestItem.CustomerID  = 1;
            TestItem.PhoneID     = 1;
            TestItem.TariffID    = 1;
            TestItem.OrderMadeBy = "Jhon";
            TestItem.OrderDate   = DateTime.Now.Date;
            TestItem.TotalPrice  = 700;
            //set ThisAddress to the test data
            AllOrders.ThisOrder = TestItem;
            //add the record
            PrimaryKey = AllOrders.Add();
            //set the primary key of the test data
            TestItem.OrderID = PrimaryKey;
            //find the record
            AllOrders.ThisOrder.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllOrders.ThisOrder, TestItem);
        }
Exemplo n.º 16
0
        public void ReportByShippingAddressTestDataFound()
        {
            //Create an instance of the filtered data
            clsOrderCollection FilteredOrders = new clsOrderCollection();
            //Var to store outcome
            Boolean OK = true;

            //Apply a shipping address that doesn't exist
            FilteredOrders.ReportByShippingAddress("yyy");
            //Check that the correct number of records are found
            if (FilteredOrders.Count == 2)
            {
                //Check that the first record is ID 57
                if (FilteredOrders.OrderList[0].OrderId != 57)
                {
                    OK = false;
                }
                //Check that the second record is ID 58
                if (FilteredOrders.OrderList[1].OrderId != 58)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            //Test to see that there are no records
            Assert.IsTrue(OK);
        }
Exemplo n.º 17
0
    //update the order
    void Update()
    {
        //create an instance of the order
        clsOrderCollection Orders = new clsOrderCollection();
        //validate the data on the web form
        String Error = Orders.ThisOrder.Valid(txtCustomerID.Text, txtStaffID.Text, txtOrderDate.Text, txtOrderStatus.Text);

        //if the data is OK then add it to the object
        if (Error == "")
        {
            //find the record to update
            Orders.ThisOrder.Find(OrderID);
            //get the data entered by the user
            Orders.ThisOrder.CustomerID  = Convert.ToInt32(txtCustomerID.Text);
            Orders.ThisOrder.StaffID     = Convert.ToInt32(txtStaffID.Text);
            Orders.ThisOrder.OrderDate   = Convert.ToDateTime(txtOrderDate.Text);
            Orders.ThisOrder.OrderStatus = txtOrderStatus.Text;
            //update the order
            Orders.Update();
            //redirect to the main page
            Response.Redirect("OrderList.aspx");
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the data entered: <br /><br /><br /><br /> " + Error;
        }
    }
Exemplo n.º 18
0
        public void AddMethodOK()
        {
            //Create an instance of the class we want to create
            clsOrderCollection AllOrders = new clsOrderCollection();
            //Create the item of test data
            clsOrder TestItem = new clsOrder();
            //Var to store the primary key
            Int32 PrimaryKey = 0;

            //Set its properties
            TestItem.Delivery        = true;
            TestItem.OrderId         = 1;
            TestItem.OrderQuantity   = 1;
            TestItem.ShippingAddress = "22 New Park St";
            TestItem.Description     = "ADIDAS";
            TestItem.DateAdded       = DateTime.Parse("03/01/2021");
            //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;
            //Find the record
            AllOrders.ThisOrder.Find(PrimaryKey);
            //Test to see that the two values are the same
            Assert.AreEqual(AllOrders.ThisOrder, TestItem);
        }
Exemplo n.º 19
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //create an instance of the class
        clsOrder AnOrder = new clsOrder();
        //create a set of string variables
        string cID          = txtCustomerId.Text;
        string cAddress     = txtCustomerAddress.Text;
        string itemName     = txtItemName.Text;
        string dateDispatch = txtDispatchDate.Text;
        string itemQuantity = txtItemQuantity.Text;
        string Error        = "";

        Error = AnOrder.Valid(cID, cAddress, dateDispatch, itemName, itemQuantity);
        if (Error == "")
        {
            //capture OrderId
            AnOrder.OrderId = OrderId;
            //capture CustomerId
            AnOrder.CustomerId = Convert.ToInt32(cID);
            //Capture the address
            AnOrder.Address = cAddress;
            //capture the item name
            AnOrder.ItemName = itemName;
            //capture the item quantity
            AnOrder.ItemQuantity = Convert.ToInt32(itemQuantity);
            //capture the date for dispatch
            AnOrder.DateDispatch = Convert.ToDateTime(dateDispatch);
            //capture the order made
            AnOrder.Made = chkActive.Checked;
            //create a new instance of the order collection
            clsOrderCollection OrderList = new clsOrderCollection();

            //if this is a new record then add the data
            if (OrderId != -1)
            {
                //set the ThisOrder property
                OrderList.ThisOrder = AnOrder;
                //add the new record
                OrderList.Add();
            }
            //otherwsie it has to be an update
            else
            {
                //fidn the property
                OrderList.ThisOrder.Find(OrderId);
                //set the ThisOrder property
                OrderList.ThisOrder = AnOrder;
                //update the record
                OrderList.Update();
            }
            Response.Redirect("OrderList.aspx");
        }

        else
        {
            //display the error message
            lblError.Text = Error;
        }
    }
Exemplo n.º 20
0
        public void TwoRecordsPresentOK()
        {
            //create an instance of the class we want to create
            clsOrderCollection AllOrder = new clsOrderCollection();

            //test to see that the two values are the same
            Assert.AreEqual(AllOrder.Count, 2);
        }
Exemplo n.º 21
0
        public void InstanceOK()
        {
            //create an instance of the class we want to create
            clsOrderCollection AllOrder = new clsOrderCollection();

            //test to see that it exists
            Assert.IsNotNull(AllOrder);
        }
Exemplo n.º 22
0
        public void ReportByAddressMethodOK()
        {
            clsOrderCollection AllOrders       = new clsOrderCollection();
            clsOrderCollection FilteredAddress = new clsOrderCollection();

            FilteredAddress.ReportByAddress("");
            Assert.AreEqual(AllOrders.Count, FilteredAddress.Count);
        }
        public void ReportByShippingMethodMethodOK()
        {
            clsOrderCollection AllOrders    = new clsOrderCollection();
            clsOrderCollection FilterOrders = new clsOrderCollection();

            FilterOrders.ReportByShippingMethod("");
            Assert.AreEqual(AllOrders.Count, FilterOrders.Count);
        }
        public void CountOK()
        {
            clsOrderCollection ordercol = new clsOrderCollection();
            int test = 5;

            ordercol.count = test;
            Assert.AreEqual(ordercol.count, test);
        }
Exemplo n.º 25
0
    protected void btnYes_Click(object sender, EventArgs e)
    {
        clsOrderCollection OrdersPage = new clsOrderCollection();

        OrdersPage.ThisOrder.Find(OrderNumber);
        OrdersPage.Delete();
        Response.Redirect("OrderList.aspx");
    }
Exemplo n.º 26
0
        public void FilterByProductNameNoneFound()
        {
            clsOrderCollection FilteredOrders = new clsOrderCollection();

            FilteredOrders.FilterByProductName("CXSC CPU");
            //Test to see there are no records
            Assert.AreEqual(0, FilteredOrders.Count);
        }
Exemplo n.º 27
0
        public void FilterByProductNameMethodOK()
        {
            clsOrderCollection AllOrders      = new clsOrderCollection();
            clsOrderCollection FilteredOrders = new clsOrderCollection();

            FilteredOrders.FilterByProductName("");
            Assert.AreEqual(AllOrders.Count, FilteredOrders.Count);
        }
Exemplo n.º 28
0
        public void ReportByGameTitleMethodOK() //check if title method works
        {
            clsOrderCollection AllOrders      = new clsOrderCollection();
            clsOrderCollection FilteredOrders = new clsOrderCollection();

            FilteredOrders.ReportByGameTitle("");
            Assert.AreEqual(AllOrders.Count, FilteredOrders.Count);
        }
Exemplo n.º 29
0
    protected void Button_Yes_Click(object sender, EventArgs e)
    {
        clsOrderCollection OrderBook = new clsOrderCollection();

        OrderBook.ThisOrder.Find(ONumber);
        OrderBook.Delete();
        Response.Redirect("OrderList.aspx");
    }
Exemplo n.º 30
0
        public void ReportByDescriptionMethodOK()
        {
            clsOrderCollection AllOrders      = new clsOrderCollection();
            clsOrderCollection FilteredOrders = new clsOrderCollection();

            FilteredOrders.ReportByDescription("");
            Assert.AreEqual(AllOrders.Count, FilteredOrders.Count);
        }