Пример #1
0
        public void Pick_WhenRequestedLessThanOwnedTokens_ReturnsCorrectAmount(int mintAmount, int pickAmount)
        {
            IReadOnlyTaggedTokens tokens       = this.fungibleTagger.Tag(this.defaultAddress, mintAmount);
            IReadOnlyTaggedTokens pickedTokens = this.fungiblePicker.Pick(tokens, pickAmount);

            Assert.Equal(pickAmount, pickedTokens.TotalBalanceByTag(FungibleTokenTagger.TokenTag));
        }
        public IReadOnlyTaggedTokens Pick(IReadOnlyTaggedTokens tokens, BigInteger amount)
        {
            if (amount < 0)
            {
                throw new NonPositiveTokenAmountException(nameof(amount), amount);
            }

            BigInteger availableTokens = tokens.TotalBalanceByTag(TokenTag);

            if (availableTokens < amount)
            {
                throw new InsufficientTokenAmountException(nameof(amount), availableTokens, amount);
            }

            var pickedTokens = new ReadOnlyTaggedTokens(new SortedDictionary <string, BigInteger>
            {
                [TokenTag] = amount,
            });

            return(pickedTokens);
        }
Пример #3
0
        public void Tag_WhenPassedValidAddressAndAmount_TagsTokensEvenly(int amount)
        {
            IReadOnlyTaggedTokens tokens = this.fungibleTagger.Tag(this.defaultAddress, amount);

            Assert.Equal(amount, tokens.TotalBalanceByTag(FungibleTokenTagger.TokenTag));
        }