Test.CBORObjectTest.TestReadJSON C# (CSharp) Méthode

TestReadJSON() private méthode

private TestReadJSON ( ) : void
Résultat void
        public void TestReadJSON()
        {
            try {
            using (var ms2 = new MemoryStream(new byte[] { 0x30 })) {
              try {
            CBORObject.ReadJSON(ms2, null);
            Assert.Fail("Should have failed");
              } catch (ArgumentNullException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var ms = new MemoryStream(new byte[] { 0xef, 0xbb, 0xbf, 0x7b,
            0x7d })) {
              try {
            CBORObject.ReadJSON(ms);
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            // whitespace followed by BOM
            using (var ms2 = new MemoryStream(new byte[] { 0x20, 0xef, 0xbb, 0xbf,
            0x7b, 0x7d })) {
              try {
            CBORObject.ReadJSON(ms2);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var ms2a = new MemoryStream(new byte[] { 0x7b, 0x05, 0x7d })) {
              try {
            CBORObject.ReadJSON(ms2a);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var ms2b = new MemoryStream(new byte[] { 0x05, 0x7b, 0x7d })) {
              try {
            CBORObject.ReadJSON(ms2b);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            // two BOMs
            using (var ms3 = new MemoryStream(new byte[] { 0xef, 0xbb, 0xbf, 0xef,
            0xbb, 0xbf, 0x7b, 0x7d })) {
              try {
            CBORObject.ReadJSON(ms3);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0xfe, 0xff, 0,
              0,
            0,
                    0x74, 0, 0, 0, 0x72, 0, 0, 0, 0x75, 0, 0, 0,
                    0x65 })) {
              Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson));
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0, 0x74, 0, 0,
            0, 0x72, 0,
                    0, 0, 0x75, 0, 0, 0, 0x65 })) {
              Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson));
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0, 0,
            0x74, 0, 0, 0,
                    0x72, 0, 0, 0, 0x75, 0, 0, 0, 0x65, 0, 0, 0 })) {
              Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson));
            }
            using (var msjson = new MemoryStream(new byte[] { 0x74, 0, 0, 0, 0x72,
              0,
              0,
            0,
                    0x75, 0, 0, 0, 0x65, 0, 0, 0 })) {
              Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson));
            }
            using (var msjson = new MemoryStream(new byte[] { 0xfe, 0xff, 0, 0x74,
            0, 0x72, 0,
                    0x75, 0, 0x65 })) {
              Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson));
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0x74, 0, 0x72, 0,
            0x75, 0, 0x65 })) {
              Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson));
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0x74, 0,
              0x72,
            0,
                    0x75,
                    0, 0x65, 0 })) {
              Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson));
            }
            using (var msjson = new MemoryStream(new byte[] { 0x74, 0, 0x72, 0,
            0x75, 0, 0x65, 0 })) {
              Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson));
            }
            using (var msjson = new MemoryStream(new byte[] { 0xef, 0xbb, 0xbf,
            0x74, 0x72, 0x75,
               0x65 })) {
              Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson));
            }
             using (var msjson = new MemoryStream(new byte[] { 0x74, 0x72, 0x75, 0x65 })) {
              Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson));
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0xfe, 0xff, 0,
            0, 0, 0x22,
                    0, 1, 0, 0, 0, 0, 0, 0x22 })) {
              {
            string stringTemp = CBORObject.ReadJSON(msjson).AsString();
            Assert.AreEqual(
            "\ud800\udc00",
            stringTemp);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0, 0x22, 0, 1,
            0, 0, 0, 0,
                    0, 0x22 })) {
              {
            string stringTemp = CBORObject.ReadJSON(msjson).AsString();
            Assert.AreEqual(
            "\ud800\udc00",
            stringTemp);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0, 0,
            0x22, 0, 0, 0,
                    0, 0, 1, 0, 0x22, 0, 0, 0 })) {
              {
            string stringTemp = CBORObject.ReadJSON(msjson).AsString();
            Assert.AreEqual(
            "\ud800\udc00",
            stringTemp);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0x22, 0, 0, 0, 0, 0,
            1, 0, 0x22,
                    0,
                    0, 0 })) {
              {
            string stringTemp = CBORObject.ReadJSON(msjson).AsString();
            Assert.AreEqual(
            "\ud800\udc00",
            stringTemp);
              }
            }
               using (var msjson = new MemoryStream(new byte[] { 0xfe, 0xff, 0, 0x22, 0xd8,
            0,
                    0xdc, 0, 0, 0x22 })) {
              {
            string stringTemp = CBORObject.ReadJSON(msjson).AsString();
            Assert.AreEqual(
            "\ud800\udc00",
            stringTemp);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0x22, 0xd8, 0,
            0xdc, 0, 0, 0x22 })) {
              {
            string stringTemp = CBORObject.ReadJSON(msjson).AsString();
            Assert.AreEqual(
            "\ud800\udc00",
            stringTemp);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0x22, 0,
            0, 0xd8, 0,
                    0xdc, 0x22, 0 })) {
              {
            string stringTemp = CBORObject.ReadJSON(msjson).AsString();
            Assert.AreEqual(
            "\ud800\udc00",
            stringTemp);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0x22, 0, 0, 0xd8, 0,
            0xdc, 0x22, 0 })) {
              {
            string stringTemp = CBORObject.ReadJSON(msjson).AsString();
            Assert.AreEqual(
            "\ud800\udc00",
            stringTemp);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0xfe, 0xff, 0,
            0, 0, 0x22,
                    0, 0, 0xd8, 0, 0, 0, 0, 0x22 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0, 0x22, 0, 0,
            0xd8, 0, 0,
                    0,
                    0, 0x22 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0, 0,
            0x22, 0, 0, 0,
                    0, 0xd8, 0, 0, 0x22, 0, 0, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0x22, 0, 0, 0, 0,
              0xd8,
              0,
            0,
                    0x22, 0, 0, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xfe, 0xff, 0, 0x22,
            0, 0xdc, 0,
                    0xdc, 0, 0, 0x22 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0x22, 0, 0xdc, 0,
            0xdc, 0, 0,
                    0x22 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0x22, 0,
            0, 0xdc, 0,
                    0xdc, 0x22, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0x22, 0, 0, 0xdc, 0,
            0xdc, 0x22, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xfc })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            // Illegal UTF-16
            using (var msjson = new MemoryStream(new byte[] { 0xfe, 0xff, 0x20,
            0x20, 0x20 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0x20,
            0x20, 0x20 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
             using (var msjson = new MemoryStream(new byte[] { 0xfe, 0xff, 0xd8, 0x00 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
             using (var msjson = new MemoryStream(new byte[] { 0xfe, 0xff, 0xdc, 0x00 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xfe, 0xff, 0xd8,
            0x00, 0x20, 0x00 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xfe, 0xff, 0xdc,
            0x00, 0x20, 0x00 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xfe, 0xff, 0xd8,
            0x00, 0xd8, 0x00 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xfe, 0xff, 0xdc,
            0x00, 0xd8, 0x00 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xfe, 0xff, 0xdc,
            0x00, 0xd8, 0x00, 0xdc, 0x00 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xfe, 0xff, 0xdc,
            0x00, 0xdc, 0x00 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }

             using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0x00, 0xd8 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
             using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0x00, 0xdc })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0x00,
            0xd8, 0x00, 0x20 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0x00,
            0xdc, 0x00, 0x20 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0x00,
            0xd8, 0x00, 0xd8 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0x00,
            0xdc, 0x00, 0xd8 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0x00,
            0xdc, 0x00, 0xd8, 0x00, 0xdc })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0xff, 0xfe, 0x00,
            0xdc, 0x00, 0xdc })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }

            // Illegal UTF-32
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0, 0x20, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0, 0x20, 0, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
             using (var msjson = new MemoryStream(new byte[] { 0, 0, 0, 0x20, 0, 0, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0, 0x20, 0, 0,
            0xd8, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0, 0x20, 0, 0,
            0xdc, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0, 0x20, 0,
            0x11, 0x00, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0, 0x20, 0,
            0xff, 0x00, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0, 0x20, 0x1,
            0, 0x00, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0xfe, 0xff, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
             using (var msjson = new MemoryStream(new byte[] { 0, 0, 0xfe, 0xff, 0, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0xfe, 0xff, 0,
            0, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0xfe, 0xff, 0,
            0, 0xd8, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0xfe, 0xff, 0,
            0, 0xdc, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0xfe, 0xff, 0,
            0x11, 0x00, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0xfe, 0xff, 0,
            0xff, 0x00, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
            using (var msjson = new MemoryStream(new byte[] { 0, 0, 0xfe, 0xff,
            0x1, 0, 0x00, 0 })) {
              try {
            CBORObject.ReadJSON(msjson);
            Assert.Fail("Should have failed");
              } catch (CBORException) {
            new Object();
              } catch (Exception ex) {
            Assert.Fail(ex.ToString());
            throw new InvalidOperationException(String.Empty, ex);
              }
            }
              } catch (IOException ex) {
            Assert.Fail(ex.Message);
              }
        }
CBORObjectTest