Esempio n. 1
0
 public Minutes MinutesWhichCanCover(PhoneCall phoneCall, IClock clock)
 {
     if (Allowance.IsGreaterOrEqualTo(phoneCall.Minutes))
     {
         return(phoneCall.Minutes);
     }
     else
     {
         return(Allowance);
     }
 }
Esempio n. 2
0
        public void Record(
            PhoneCall phoneCall,
            PhoneCallCosting phoneCallCosting,
            IClock clock)
        {
            var numberOfMinutesCoveredByAllowance = new Minutes();

            if (_freeCallAllowance != null)
            {
                numberOfMinutesCoveredByAllowance =
                    _freeCallAllowance.MinutesWhichCanCover(phoneCall, clock);
            }

            var numberOfMinutesToChargeFor =
                phoneCall.Minutes.Subtract(numberOfMinutesCoveredByAllowance);

            var costOfCall =
                phoneCallCosting.DetermineCostOfCall(
                    numberOfMinutesToChargeFor);

            Causes(new PhoneCallCharged(this.Id, phoneCall, costOfCall,
                                        numberOfMinutesCoveredByAllowance));
        }