Ejemplo n.º 1
0
        public void Test_roundtrip(NumberConversion numberConversion)
        {
            UInt256Converter converter = new UInt256Converter(numberConversion);

            TestConverter(int.MaxValue, (integer, bigInteger) => integer.Equals(bigInteger), converter);
            TestConverter(UInt256.One, (integer, bigInteger) => integer.Equals(bigInteger), converter);
            TestConverter(UInt256.Zero, (integer, bigInteger) => integer.Equals(bigInteger), converter);
        }
Ejemplo n.º 2
0
        public void Raw_works_with_zero_and_this_is_ok()
        {
            UInt256Converter converter = new UInt256Converter(NumberConversion.Raw);

            TestConverter(0, (integer, bigInteger) => integer.Equals(bigInteger), converter);

            converter = new UInt256Converter((NumberConversion)99);
            TestConverter(0, (integer, bigInteger) => integer.Equals(bigInteger), converter);
        }
Ejemplo n.º 3
0
        public void Raw_not_supported(NumberConversion notSupportedConversion)
        {
            UInt256Converter converter = new UInt256Converter(notSupportedConversion);

            Assert.Throws <NotSupportedException>(
                () => TestConverter(int.MaxValue, (integer, bigInteger) => integer.Equals(bigInteger), converter));
            Assert.Throws <NotSupportedException>(
                () => TestConverter(UInt256.One, (integer, bigInteger) => integer.Equals(bigInteger), converter));
        }
Ejemplo n.º 4
0
        public void Throws_on_null()
        {
            UInt256Converter converter = new UInt256Converter();
            JsonReader       reader    = new JsonTextReader(new StringReader("null"));

            reader.ReadAsString();
            Assert.Throws <JsonException>(
                () => converter.ReadJson(reader, typeof(UInt256), UInt256.Zero, false, JsonSerializer.CreateDefault()));
        }
Ejemplo n.º 5
0
        public void Can_read_1()
        {
            UInt256Converter converter = new UInt256Converter();
            JsonReader       reader    = new JsonTextReader(new StringReader("1"));

            reader.ReadAsString();
            UInt256 result = converter.ReadJson(reader, typeof(UInt256), UInt256.Zero, false, JsonSerializer.CreateDefault());

            Assert.AreEqual(UInt256.Parse("1"), result);
        }
Ejemplo n.º 6
0
        public void Can_read_unmarked_hex()
        {
            UInt256Converter converter = new UInt256Converter();
            JsonReader       reader    = new JsonTextReader(new StringReader("\"de\""));

            reader.ReadAsString();
            UInt256 result = converter.ReadJson(reader, typeof(UInt256), UInt256.Zero, false, JsonSerializer.CreateDefault());

            Assert.AreEqual(UInt256.Parse("de", NumberStyles.HexNumber), result);
        }
Ejemplo n.º 7
0
        public Startup(IConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            this.network = ZcoinNetworks.Instance.GetNetwork(config.GetZcoinSection().Network.Type);
            this.bitcoinAddressConverter = new BitcoinAddressConverter(this.network);
            this.moneyConverter          = new MoneyConverter();
            this.propertyAmountConverter = new PropertyAmountConverter(config.GetZcoinSection().Property.Type);
            this.uint256Converter        = new UInt256Converter();
        }
Ejemplo n.º 8
0
 public UInt256ConverterTests()
 {
     this.subject = new UInt256Converter();
 }