Example #1
0
        public void AddRisk(string nameOfInsuredObject, Risk risk, DateTime validFrom, DateTime effectiveDate)
        {
            if (string.IsNullOrEmpty(nameOfInsuredObject))
            {
                throw new CannotBeNullException(nameof(nameOfInsuredObject));
            }

            if (validFrom.Date < DateTime.Now.Date)
            {
                throw new RiskValidFromDateInPastException();
            }

            if (!AvailableRisks.Contains(risk))
            {
                throw new RiskDoesNotExistInAvailableListException(risk.Name);
            }

            _riskService.AddRisk(nameOfInsuredObject, risk, validFrom, effectiveDate);
        }
Example #2
0
 public void AddRisk_ShouldThrowIfValidTillIsEarlierThanEffectiveDate()
 {
     Assert.That(() => RiskService.AddRisk(It.IsAny <string>(), It.IsAny <Risk>(),
                                           DateTime.Now.AddMonths(-1), DateTime.Now), Throws.Exception);
 }