public void Test_that_price_is_calculated_correctly() { // Arrange var priceExpected = 153.6M; var equipments = new List <Equipment> { new Equipment { PriceEuro = 10 }, new Equipment { PriceEuro = 15 } }; var rims = new Rims { PriceEuro = 12 }; var varnish = new Varnish { PriceEuro = 16.6M }; // Act var priceActual = _service.CalculatePrice(Currency.Euro, equipments, rims, varnish, 20); // Assert Assert.AreEqual(priceExpected, priceActual); }
public decimal CalculatePrice(Currency currency, IEnumerable <Equipment> equipments = null, Rims rims = null, Varnish varnish = null, int?enginePower = null) { var equipmentPrice = equipments?.Sum(_ => currency == Currency.Euro ? _.PriceEuro : _.PricePound) ?? decimal.Zero; var rimsesPrice = (currency == Currency.Euro ? rims?.PriceEuro : rims?.PricePound) ?? decimal.Zero; var varnishesPrice = (currency == Currency.Euro ? varnish?.PriceEuro : varnish?.PricePound) ?? decimal.Zero; var engingePowerPrice = (enginePower ?? 0) * (currency == Currency.Euro ? 5 : 4); return(equipmentPrice + rimsesPrice + varnishesPrice + engingePowerPrice); }