コード例 #1
0
        public void ScalarEncoder_Type()
        {
            var b = new BlobBuilder();
            var e = new ScalarEncoder(b);

            Assert.Same(b, e.Builder);

            e.SystemType(null);
            AssertEx.Equal(new byte[] { 0xff }, b.ToArray());
            b.Clear();

            e.SystemType("abc");
            AssertEx.Equal(new byte[] { 0x03, 0x61, 0x62, 0x63 }, b.ToArray());
            b.Clear();

            e.SystemType("\ud800"); // unpaired surrogate
            AssertEx.Equal(new byte[] { 0x03, 0xED, 0xA0, 0x80 }, b.ToArray());
            b.Clear();

            AssertExtensions.Throws <ArgumentException>("serializedTypeName", () => e.SystemType(""));
        }
コード例 #2
0
        public void ScalarEncoder_Type()
        {
            var b = new BlobBuilder();
            var e = new ScalarEncoder(b);
            Assert.Same(b, e.Builder);

            e.SystemType(null);
            AssertEx.Equal(new byte[] { 0xff }, b.ToArray());
            b.Clear();

            e.SystemType("abc");
            AssertEx.Equal(new byte[] { 0x03, 0x61, 0x62, 0x63 }, b.ToArray());
            b.Clear();

            e.SystemType("\ud800"); // unpaired surrogate
            AssertEx.Equal(new byte[] { 0x03, 0xED, 0xA0, 0x80 }, b.ToArray());
            b.Clear();

            Assert.Throws<ArgumentException>(() => e.SystemType(""));
        }