public void GetsFeeTest_Hsinchu() { Hsinchu target = new Hsinchu(); double expected = 0F; Assert.AreEqual(expected, target.GetsFee()); }
public void CalculateTest_Hsinchu() { Hsinchu target = new Hsinchu() { ShipProduct = new Product { IsNeedCool = true, Name = "test1", Size = new getSize { Height = 10, Length = 30, Width = 20 }, Weight = 10 } }; target.Calculate(); var expectedName = "Hsinchu"; var expectedFee = 254.16; var actualName = target.GetsCompanyName(); var actualFee = target.GetsFee(); Assert.AreEqual(expectedName, actualName); Assert.AreEqual(expectedFee, actualFee); }
public void CalculateTest() { Hsinchu target = new Hsinchu() { ShipProduct = new Product { IsNeedCool = true, Name = "商品測試1", Size = new Size { Height = 10, Length = 30, Width = 20 }, Weight = 10 } }; //act target.Calculate(); //assert var expectedName = "新竹貨運"; var expectedFee = 254.16; var actualName = target.GetsComapanyName(); var actualFee = target.GetsFee(); //assert Assert.AreEqual(expectedName, actualName); Assert.AreEqual(expectedFee, actualFee); }
public void GetsCompanyNameTest_Hsinchu() { Hsinchu target = new Hsinchu(); string expected = "Hsinchu"; Assert.AreEqual(expected, target.GetsCompanyName()); }
public void GetsFeeTest() { Hsinchu target = new Hsinchu(); double expected = 0F; double actual; actual = target.GetsFee(); Assert.AreEqual(expected, actual); }
public void GetsComapanyNameTest() { Hsinchu target = new Hsinchu(); string expected = "新竹貨運"; string actual; actual = target.GetsComapanyName(); Assert.AreEqual(expected, actual); }
public void GetILogisticsTest_GetHsinchu() { //arrange string p = "2"; Product product = new Product(); ILogistics expected = new Hsinchu(); ILogistics actual; //act actual = FactoryRepository.GetILogistics(p, product); //assert Assert.AreEqual(expected.GetType(), actual.GetType()); }
public ActionResult Index(ProductModels product) { var companies = new List <SelectListItem> { new SelectListItem { Text = "黑貓", Value = "1" }, new SelectListItem { Text = "新竹貨運", Value = "2" }, new SelectListItem { Text = "郵局", Value = "3" }, }; ViewBag.Company = companies; // Validation若不合法,則直接回傳 if (!ModelState.IsValid) { return(View(product)); } double fee = 0; if (product.Company == 1)// 當貨運商為黑貓時 { //fee =CalculateFeeByBlackcat(product) var blackcat = new Blackcat(); fee = blackcat.CalculateFee(product); } else if (product.Company == 2)// 當貨運商為新竹貨運時 { //fee =CalculateFeeByHsinchu(product) var hsinchu = new Hsinchu(); fee = hsinchu.CalculateFee(product); } else if (product.Company == 3)// 當貨運商為郵局時 { // fee = CalculateFeeByPostoffice(product) var postoffice = new Postoffice(); fee = postoffice.CalculateFee(product); } // 將運費結果呈現在 View 上 ViewBag.Fee = fee; return(View(product)); }
internal static IShipper GetShipper(int company) { IShipper shipper = null; if (company == 1) // 當貨運商為黑貓時 { shipper = new Blackcat(); } else if (company == 2) // 當貨運商為新竹貨運時 { shipper = new Hsinchu(); } else if (company == 3) // 當貨運商為郵局時 { shipper = new Postoffice(); } return shipper; }
internal static IShipper GetShipper(int company) { IShipper shipper = null; if (company == 1) // 當貨運商為黑貓時 { shipper = new Blackcat(); } else if (company == 2) // 當貨運商為新竹貨運時 { shipper = new Hsinchu(); } else if (company == 3) // 當貨運商為郵局時 { shipper = new Postoffice(); } return(shipper); }
public void BeforeScenario() { this.target = new Hsinchu(); }