Ejemplo n.º 1
0
        public void TestAppend()
        {
            var b = new ByteStringBuilder(16);

              Assert.AreEqual(16, b.Capacity);

              Assert.IsTrue(Object.ReferenceEquals(b, b.Append(new ByteString("0123456789"))));

              Assert.AreEqual(10, b.Length);
              Assert.AreEqual(16, b.Capacity);

              Assert.IsTrue(Object.ReferenceEquals(b, b.Append(new byte[] {0x61, 0x62, 0x63, 0x64, 0x65, 0x66})));

              Assert.AreEqual(16, b.Length);
              Assert.AreEqual(16, b.Capacity);

              Assert.IsTrue(Object.ReferenceEquals(b, b.Append((byte)0x67)));

              Assert.IsTrue(16 < b.Capacity);
              Assert.AreEqual(17, b.Length);

              Assert.IsTrue(Object.ReferenceEquals(b, b.Append("xyz")));

              Assert.AreEqual(20, b.Length);

              Assert.IsTrue(Object.ReferenceEquals(b, b.Append(new ByteString("0123456789"), 5, 3)));

              Assert.AreEqual(23, b.Length);

              Assert.AreEqual("0123456789abcdefgxyz567", b.ToString());
        }
Ejemplo n.º 2
0
        public void TestToString()
        {
            var b = new ByteStringBuilder();

              b.Append(new byte[] {0x61, 0x62, 0x63, 0x64, 0x65, 0x66});

              Assert.AreEqual("abcdef", b.ToString());

              b.Append((byte)0x67);

              Assert.AreEqual("abcdefg", b.ToString());
        }