public void GetILogisticsTest_GetPostOffice() { //arrange string p = "3"; Product product = new Product(); ILogistics expected = new PostOffice(); ILogistics actual; //act actual = FactoryRepository.GetILogistics(p, product); //Assert Assert.AreEqual(expected.GetType(), actual.GetType()); }
private void btnCalculate_Click(object sender, EventArgs e) { //取得畫面資料 Product product = this.GetProduct(); var companyName = ""; double fee = 0; ////選黑貓,計算出運費,呈現物流商名稱與運費 //if (this.drpCompany.SelectedValue.ToString() == "1") //{ // //CalculatedByBlackCat(); // //取得畫面資料 // //計算 // //BlackCat blackCat = new BlackCat() { ShipProduct = product }; // //blackCat.Calculate(); // //companyName = blackCat.GetsComapanyName(); // //fee = blackCat.GetsFee(); // ILogistics logistics = new BlackCat() { ShipProduct = product }; // logistics.Calculate(); // companyName = logistics.GetsComapanyName(); // fee = logistics.GetsFee(); //} ////選新竹貨運,計算出運費,呈現物流商名稱與運費 //else if (this.drpCompany.SelectedValue.ToString() == "2") //{ // //CalculatedByHsinchu(); // //取得畫面資料 // //計算 // //Hsinchu hsinchu = new Hsinchu() { ShipProduct = product }; // //hsinchu.Calculate(); // //companyName = hsinchu.GetsComapanyName(); // //fee = hsinchu.GetsFee(); // ILogistics logistics = new Hsinchu() { ShipProduct = product }; // logistics.Calculate(); // companyName = logistics.GetsComapanyName(); // fee = logistics.GetsFee(); //} ////選郵局,計算出運費,呈現物流商名稱與運費 //else if (this.drpCompany.SelectedValue.ToString() == "3") //{ // //CalculatedByPostOffice(); // //取得畫面資料 // //計算 // //PostOffice postOffice = new PostOffice() { ShipProduct = product }; // //postOffice.Calculate(); // //companyName = postOffice.GetsComapanyName(); // //fee = postOffice.GetsFee(); // ILogistics logistics = new PostOffice() { ShipProduct = product }; // logistics.Calculate(); // companyName = logistics.GetsComapanyName(); // fee = logistics.GetsFee(); //} //ILogistics logistics = this.GetILogistics(this.drpCompany.SelectedValue.ToString(), product); ILogistics logistics = FactoryRepository.GetILogistics(this.drpCompany.SelectedValue.ToString(), product); if (logistics != null) { logistics.Calculate(); companyName = logistics.GetsComapanyName(); fee = logistics.GetsFee(); //呈現結果 this.SetResult(companyName, fee); } //發生預期以外的狀況,呈現警告訊息,回首頁 else { var js = "alert('發生不預期錯誤,請洽系統管理者');location.href='http://tw.yahoo.com/';"; // this.ClientScript.RegisterStartupScript(this.GetType(), "back", js, true); } //呈現結果 this.SetResult(companyName, fee); }