public static void CalculateCallCostTest( [Values("+79601258111")]string callingNumber, [Values("+79503468221")]string calledNumber, [Values("12.10.2012 11:13")]DateTime startTime, [Values("12.10.2012 11:15")]DateTime endTime) { Call call = new Call(calledNumber, calledNumber, startTime, endTime); Tariff tariff = Tariff.SelectTariffByID(6); StringAssert.Contains(BillingOperations.CalculateCallCost(call, tariff).ToString(), "48"); }
/// <summary> /// Рассчитывает стоимость звонка. /// </summary> /// <param name="call">Звонок</param> /// <param name="tariff">Тариф</param> /// <returns>Стоимость</returns> public static double CalculateCallCost(Call call, Tariff tariff) { Price price = tariff.SelectCallPrice(call.CalledNumber); double cost = price.Cost * (call.Duration.TotalSeconds); return Math.Round(cost, 2); }