Exemplo n.º 1
0
        public void FindMediumPackage()
        {
            int           lenght    = 300;
            int           breadth   = 400;
            int           height    = 200;
            double        weight    = 20;
            ParcelService obj       = new ParcelService(lenght, breadth, height, weight);
            ParcelType    resultobj = new ParcelType();

            resultobj = obj.CalculateParcelCost();
            Assert.AreEqual <string>(resultobj._type, Constants.MEDIUM_Type);
            Assert.AreEqual <decimal>(resultobj._cost, Constants.MEDIUM_COST);
        }
Exemplo n.º 2
0
        public void Morehan25Kg_WontFindParcel()
        {
            int           lenght    = 1;
            int           breadth   = 1;
            int           height    = 1;
            double        weight    = 26;
            ParcelService obj       = new ParcelService(lenght, breadth, height, weight);
            ParcelType    resultobj = new ParcelType();

            resultobj = obj.CalculateParcelCost();
            Assert.AreEqual(resultobj._type, string.Empty);
            Assert.AreEqual <decimal>(resultobj._cost, 0);
        }
Exemplo n.º 3
0
        public void TooBigHeight_WontFindPackage()
        {
            int           lenght    = 900;
            int           breadth   = 300;
            int           height    = 900;
            double        weight    = 20;
            ParcelService obj       = new ParcelService(lenght, breadth, height, weight);
            ParcelType    resultobj = new ParcelType();

            resultobj = obj.CalculateParcelCost();
            Assert.AreEqual(resultobj._type, string.Empty);
            Assert.AreEqual <decimal>(resultobj._cost, 0);
        }
Exemplo n.º 4
0
        void formatInputOutput()
        {
            try
            {
                int           lenght    = Int32.Parse(txtLen.Text);
                int           breadth   = Int32.Parse(txtBrd.Text);
                int           height    = Int32.Parse(txtHgt.Text);
                double        weight    = Int32.Parse(txtwght.Text);
                ParcelService obj       = new ParcelService(lenght, breadth, height, weight);
                ParcelType    resultobj = new ParcelType();
                resultobj = obj.CalculateParcelCost();
                decimal resultCost = resultobj._cost;
                string  resultType = resultobj._type;

                if (resultType == string.Empty && resultCost == 0)
                {
                    Label3.Text           = "Invalid Item - Cannot find type and cost";
                    Label3.Visible        = true;
                    lblParcelType.Visible = false;
                    Label1.Visible        = false;
                    lblParcelCost.Visible = false;
                    Label2.Visible        = false;
                }

                else
                {
                    lblParcelType.Text    = resultType;
                    lblParcelType.Visible = true;
                    Label1.Visible        = true;
                    lblParcelCost.Text    = resultCost.ToString();
                    lblParcelCost.Visible = true;
                    Label2.Visible        = true;
                    Label3.Visible        = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }