示例#1
0
        public void TestToLoop()
        {
            var loop = BigInteger.Parse("1000000000000000000");

            var amount = IconAmount.Of("1", IconAmount.Unit.ICX);

            Assert.Equal(loop, amount.ToLoop());

            amount = IconAmount.Of("1000000000000000000", IconAmount.Unit.Loop);
            Assert.Equal(loop, amount.ToLoop());

            amount = IconAmount.Of(BigInteger.Parse("1"), IconAmount.Unit.ICX);
            Assert.Equal(loop, amount.ToLoop());

            amount = IconAmount.Of(BigInteger.Parse("1000"), IconAmount.Unit.ICX);
            Assert.Equal(BigInteger.Parse("1000000000000000000000"), amount.ToLoop());

            amount = IconAmount.Of("0.1", IconAmount.Unit.ICX);
            var loop2 = amount.ToLoop();

            Assert.Equal(BigInteger.Parse("100000000000000000"), loop2);

            amount = IconAmount.Of(BigDecimal.Parse("0.1"), IconAmount.Unit.ICX);
            Assert.Equal(BigInteger.Parse("100000000000000000"), amount.ToLoop());
        }
示例#2
0
        public async Task TestGetBalance()
        {
            var balance = await _iconService.GetBalance(_wallet.GetAddress());

            // ReSharper disable once UnusedVariable
            var amount = IconAmount.Of(balance, IconAmount.Unit.ICX);

            Assert.True(balance >= 0);
        }
示例#3
0
        public void TestConvertUnit()
        {
            var amount = IconAmount.Of("1", IconAmount.Unit.ICX);

            Assert.Equal(BigInteger.Parse("10"), amount.ConvertUnit(17).ToInteger());

            amount = IconAmount.Of("1", IconAmount.Unit.ICX);
            Assert.Equal(BigInteger.Parse("100"), amount.ConvertUnit(16).ToInteger());

            amount = IconAmount.Of(BigDecimal.Parse("1"), IconAmount.Unit.ICX);
            Assert.Equal(BigDecimal.Parse("0.1"), amount.ConvertUnit(19).ToDecimal());

            amount = IconAmount.Of(BigDecimal.Parse("1"), IconAmount.Unit.ICX);
            Assert.Equal(BigInteger.Parse("1000000000000000000"), amount.ConvertUnit(IconAmount.Unit.Loop).ToInteger());
        }
示例#4
0
        public void TestCreate()
        {
            var amount = IconAmount.Of("1", IconAmount.Unit.ICX);

            Assert.Equal(BigInteger.Parse("1"), amount.ToInteger());
            Assert.Equal(IconAmount.Unit.ICX, amount.GetDigit());

            amount = IconAmount.Of("1000000000000000000", IconAmount.Unit.Loop);
            Assert.Equal("1000000000000000000", amount.ToString());
            Assert.Equal(IconAmount.Unit.Loop, amount.GetDigit());

            amount = IconAmount.Of(BigInteger.Parse("1000000000000000000"), 16);
            Assert.Equal(BigInteger.Parse("1000000000000000000"), amount.ToInteger());
            Assert.Equal(16, amount.GetDigit());

            amount = IconAmount.Of(BigDecimal.Parse("0.1"), IconAmount.Unit.ICX);
            Assert.Equal(BigDecimal.Parse("0.1"), amount.ToDecimal());
            Assert.Equal(IconAmount.Unit.ICX, amount.GetDigit());

            amount = IconAmount.Of(BigDecimal.Parse("0.1"), 16);
            Assert.Equal(BigDecimal.Parse("0.1"), amount.ToDecimal());
            Assert.Equal(16, amount.GetDigit());
        }