public decimal TestCarImportTaxRate(string name, decimal originalPrice, decimal capacity, StaticData.Country importFrom) { var carFactory = new CarFactory(); var car = carFactory.CreateCar(name, originalPrice, capacity, importFrom); return(car.ImportTaxRate); }
public Car(string name, decimal originalPrice, decimal capacity, StaticData.Country importFrom, decimal importTaxRate) { Name = name; OriginalPrice = originalPrice; Capacity = capacity; ImportedFrom = importFrom; ImportTaxRate = importTaxRate; }
public decimal TestCalculateEndUserPrice(string name, decimal originalPrice, decimal capacity, StaticData.Country importFrom) { var carFactory = new CarFactory(); var calculator = new Calculator(); var car = carFactory.CreateCar(name, originalPrice, capacity, importFrom); var endUserPrice = calculator.CalculateEndUserPrice(car); return(endUserPrice); }
public Car CreateCar(string name, decimal originalPrice, decimal capacity, StaticData.Country importFrom) { var importedRegion = GetImportedRegion(importFrom); var importTaxRateTable = StaticData.RegionImportTaxRateTable[importedRegion]; var importTaxRate = importTaxRateTable[importTaxRateTable.Keys.Single(x => x(capacity))]; var car = new Car(name, originalPrice, capacity, importFrom, importTaxRate); return(car); }
public void TestCreateChinaCar(string name, decimal originalPrice, decimal capacity, StaticData.Country importFrom) { var carFactory = new CarFactory(); var ex = Assert.Throws <Exception>( () => carFactory.CreateCar(name, originalPrice, capacity, importFrom) ); StringAssert.Contains("Not support this country", ex.Message); }
private static StaticData.ImportedRegion GetImportedRegion(StaticData.Country importFrom) { try { return(StaticData.CountryRegions[importFrom]); } catch { throw new Exception("Not support this country"); } }