/// <summary>
        /// Create new transaction with validation
        /// </summary>
        /// <param name="sum">Sum of the transaction</param>
        /// <param name="from">Link card from</param>
        /// <param name="to">Link card to</param>
        public Transaction(decimal sum, Card from, Card to)
        {
            if (from == null)
            {
                throw new BusinessLogicException(TypeBusinessException.TRANSACTION,
                                                 "From card is null", "Не найдена карта с которой совершается перевод");
            }

            if (to == null)
            {
                throw new BusinessLogicException(TypeBusinessException.TRANSACTION,
                                                 "To card is null", "Не найдена карта на которую совершается перевод");
            }

            if (from.CardNumber == to.CardNumber)
            {
                throw new BusinessLogicException(TypeBusinessException.TRANSACTION,
                                                 "From card and to card is Equal", "Нельзя перевести на туже карту");
            }

            if (sum <= 0)
            {
                throw new UserDataException("Transaction need more then 0", $"from {from.CardName} to {to.CardName}");
            }

            if (!blService.CheckCardActivity(from))
            {
                throw new BusinessLogicException(TypeBusinessException.CARD,
                                                 "Card is expired", $"Карта {from.CardNumber } просрочена");
            }

            if (!blService.CheckCardActivity(to))
            {
                throw new BusinessLogicException(TypeBusinessException.CARD,
                                                 "Card is expired", $"Карта {to.CardNumber } просрочена");
            }

            if (blService.GetBalanceOfCard(from) < sum)
            {
                throw new BusinessLogicException(TypeBusinessException.CARD,
                                                 "No money", $" Недостаточно средств на карте {from.CardNumber }");
            }

            CardFromNumber = from.CardNumber;
            CardToNumber   = to.CardNumber;
            FromSum        = sum;
            ToSum          = blService.GetConvertSum(sum, from.Currency, to.Currency);
        }
        public void CheckCardActivityPasses()
        {
            var card = new Card
            {
                CardName   = "4790878827491205",
                CardNumber = "4790878827491205",
                CardType   = CardType.VISA,
                Currency   = Currency.RUR,
                DTOpenCard = DateTime.Today.AddYears(-6)
            };

            Assert.False(_businessLogicService.CheckCardActivity(card));
        }
 public void CheckCardActivityException()
 => Assert.Throws <BusinessLogicException>(() => blservice.CheckCardActivity(null));