Ejemplo n.º 1
0
        public void ValidMethodOK()
        {
            clsShipping AShipment = new clsShipping();
            String      Error     = "";

            Error = AShipment.Valid(DateOfDispatch);
            Assert.AreEqual(Error, "");
        }
Ejemplo n.º 2
0
        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
        }
Ejemplo n.º 3
0
        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
        }
Ejemplo n.º 4
0
        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
        }
Ejemplo n.º 5
0
        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
        }
Ejemplo n.º 6
0
        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
        }
Ejemplo n.º 7
0
        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
        }
Ejemplo n.º 8
0
        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
        }
    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;
        }
    }