Ejemplo n.º 1
0
        public void QuickTestsOnKeyIdBytes()
        {
            var a  = new KeyId("93e5d305cad2588d5fb254065fe48ce446028ba3");
            var b  = new ScriptId("93e5d305cad2588d5fb254065fe48ce446028ba3");
            var b2 = new WitKeyId("93e5d305cad2588d5fb254065fe48ce446028ba3");

            Assert.Equal(a.ToString(), b.ToString());
            Assert.Equal(a.ToString(), b2.ToString());
            Assert.Equal("93e5d305cad2588d5fb254065fe48ce446028ba3", a.ToString());
            var bytes = Encoders.Hex.DecodeData("93e5d305cad2588d5fb254065fe48ce446028ba3");

            Assert.True(StructuralComparisons.StructuralComparer.Compare(a.ToBytes(), b.ToBytes()) == 0);
            Assert.True(StructuralComparisons.StructuralComparer.Compare(b2.ToBytes(), b.ToBytes()) == 0);

            var c  = new KeyId(bytes);
            var d  = new ScriptId(bytes);
            var d2 = new WitKeyId(bytes);

            Assert.Equal(a, c);
            Assert.Equal(d, b);
            Assert.Equal(b2, d2);
            Assert.Equal(c.ToString(), d.ToString());
            Assert.Equal(c.ToString(), d2.ToString());
            Assert.Equal("93e5d305cad2588d5fb254065fe48ce446028ba3", c.ToString());
            Assert.True(StructuralComparisons.StructuralComparer.Compare(c.ToBytes(), d.ToBytes()) == 0);
            Assert.True(StructuralComparisons.StructuralComparer.Compare(c.ToBytes(), d2.ToBytes()) == 0);

            var e = new WitScriptId("93e5d305cad2588d5fb254065fe48ce446028ba380e6ee663baea9cd10550089");

            Assert.Equal("93e5d305cad2588d5fb254065fe48ce446028ba380e6ee663baea9cd10550089", e.ToString());
            bytes = Encoders.Hex.DecodeData("93e5d305cad2588d5fb254065fe48ce446028ba380e6ee663baea9cd10550089");
            var e2 = new WitScriptId(bytes);

            Assert.Equal(e, e2);
        }
        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            Func <string, object, string> f = (n, o) => string.Format(CultureInfo.InvariantCulture, "{0,45}: {1}", n, o);
            var builder = new StringBuilder();

            builder.AppendLine(f("Script Id", ScriptId.ToString("X2")));
            builder.AppendLine(f("Before 2nd generate", BeforeSecondGenerate));
            builder.AppendLine(f("Number of Scripts", NumberOfScripts));
            Scripts.ForIndex((i, x) => builder.AppendLine(f("Script " + i, x)));
            return(builder.ToString());
        }