Ejemplo n.º 1
0
        public void EncodeDecodeTest(string toDecode, string coin, string addr, decimal amnt, string lbl, string msg)
        {
            BIP0021 actual = BIP0021.Decode(toDecode);

            Assert.Equal(coin, actual.Scheme);
            Assert.Equal(addr, actual.Address);
            Assert.Equal(amnt, actual.Amount);
            Assert.Equal(lbl, actual.Label);
            Assert.Equal(msg, actual.Message);

            string actualStr = actual.Encode();

            Assert.Equal(toDecode, actualStr);
        }
Ejemplo n.º 2
0
        public void EncodeDecode_SpecialCasesTest()
        {
            BIP0021 actual = BIP0021.Decode("BitCoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?" +
                                            "somethingyoudontunderstand=50&message=&somethingelseyoudontget=999&Foo=baR");

            Assert.Equal("bitcoin", actual.Scheme);
            Assert.Equal("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W", actual.Address);
            Assert.Equal(0m, actual.Amount);
            Assert.Null(actual.Label);
            // Message is null even though it exists in the string
            Assert.Null(actual.Message);
            Assert.Equal(3, actual.AdditionalOptions.Count);
            Assert.Equal("50", actual.AdditionalOptions["somethingyoudontunderstand"]);
            Assert.Equal("999", actual.AdditionalOptions["somethingelseyoudontget"]);
            Assert.Equal("baR", actual.AdditionalOptions["Foo"]);
        }
Ejemplo n.º 3
0
        public void ConstructorTest()
        {
            BIP0021 bip = new BIP0021("TheAddress", "FoO");

            // Address is not changed but scheme is lowered
            Assert.Equal("foo", bip.Scheme);
            Assert.Equal("TheAddress", bip.Address);
            Assert.Equal(0m, bip.Amount);
            Assert.Null(bip.Label);
            Assert.Null(bip.Message);
            Assert.Empty(bip.AdditionalOptions);

            bip.Amount = 20.3m;
            Assert.Equal(20.3m, bip.Amount);

            // Labels,... are not changed here. They are changed before encoding.
            bip.Label = "Some Label";
            Assert.Equal("Some Label", bip.Label);

            bip.Message = "Some Message";
            Assert.Equal("Some Message", bip.Message);
        }
Ejemplo n.º 4
0
        public void Decode_FormatExceptionTest(string toDecode, string expErr)
        {
            Exception ex = Assert.Throws <FormatException>(() => BIP0021.Decode(toDecode));

            Assert.Contains(expErr, ex.Message);
        }