示例#1
0
        public void GetShipper_沒有輸入貨運商代碼_應拋出ArgumentNullException()
        {
            // arrange
            var companyCode = "";

            // act
            var actual = ShipperFactory.Create(companyCode);
        }
示例#2
0
        public void GetShipper_貨運商代碼輸入3_應回傳郵局()
        {
            // arrange
            var companyCode = "3";
            var expected    = "郵局";

            // act
            var actual = ShipperFactory.Create(companyCode);

            // assert
            Assert.AreEqual(expected, actual.Name);
        }
    protected void btnCalculate_Click(object sender, EventArgs e)
    {
        if (!this.IsValid)
        {
            return;
        }

        var product     = this.GetShippingProduct();
        var companyCode = this.drpCompany.SelectedValue;

        IShipper shipper = ShipperFactory.Create(companyCode);

        if (shipper == null)
        {
            var js = "alert('發生不預期錯誤,請洽系統管理者');location.href='http://tw.yahoo.com/';";
            this.ClientScript.RegisterStartupScript(this.GetType(), "back", js, true);
        }
        else
        {
            shipper.CalculateFee(product);
            this.lblCompany.Text = shipper.Name;
            this.lblCharge.Text  = product.ShippingFee.ToString();
        }
    }