Пример #1
0
        public void ReadAsInt32BadString()
        {
            AssertException.Throws<JsonReaderException>(() =>
            {
                byte[] data = HexToBytes("20-00-00-00-02-30-00-02-00-00-00-61-00-02-31-00-02-00-00-00-62-00-02-32-00-02-00-00-00-63-00-00");

                MemoryStream ms = new MemoryStream(data);
                BsonReader reader = new BsonReader(ms);

                Assert.Equal(false, reader.ReadRootValueAsArray);
                Assert.Equal(DateTimeKind.Local, reader.DateTimeKindHandling);

                reader.ReadRootValueAsArray = true;
                reader.DateTimeKindHandling = DateTimeKind.Utc;

                Assert.Equal(true, reader.ReadRootValueAsArray);
                Assert.Equal(DateTimeKind.Utc, reader.DateTimeKindHandling);

                Assert.True(reader.Read());
                Assert.Equal(JsonToken.StartArray, reader.TokenType);

                reader.ReadAsInt32();
            }, "Could not convert string to integer: a. Path '[0]'.");
        }