public void ValidateAndPutCoinsOnDeposit(int denomination, int amount)
        {
            ValidateDenomination(denomination);

            var newSet = new CoinSet {
                Denomination = denomination, Amount = amount
            };

            var existingSet = _deposit.SingleOrDefault(s => s.Denomination == denomination);

            if (existingSet == default)
            {
                _deposit.Add(newSet);
            }
            else
            {
                existingSet.Amount += amount;
            }

            AddDomainEvent(new DepositChangedEvent(_deposit.Sum(c => c.Amount * c.Denomination).ToAmounDenominationString()));
        }
        private IEnumerable <CoinSet> CalculateChange(int amount)
        {
            var minimumChange = new List <CoinSet>();

            for (var i = _denominations.Length - 1; i >= 0; i--)
            {
                var currentDenomination = _denominations[i];
                while (amount >= currentDenomination)
                {
                    amount -= currentDenomination;
                    var coinsOfDenomination = minimumChange.SingleOrDefault(c => c.Denomination == currentDenomination);
                    if (coinsOfDenomination == default)
                    {
                        coinsOfDenomination = new CoinSet {
                            Denomination = currentDenomination, Amount = 0
                        };
                        minimumChange.Add(coinsOfDenomination);
                    }
                    coinsOfDenomination.Amount++;
                }
            }

            return(minimumChange);
        }