Exemplo n.º 1
0
        public void ReadAsBoolean_Integer_Success()
        {
            JValue n = new JValue(1);

            JTokenReader reader = new JTokenReader(n);

            Assert.AreEqual(true, reader.ReadAsBoolean());
        }
Exemplo n.º 2
0
        public void ReadAsBoolean_Null_Success()
        {
            JValue n = JValue.CreateNull();

            JTokenReader reader = new JTokenReader(n);

            Assert.AreEqual(null, reader.ReadAsBoolean());
        }
Exemplo n.º 3
0
        public void ReadAsBoolean_BigInteger_Success()
        {
            JValue s = new JValue(BigInteger.Parse("99999999999999999999999999999999999999999999999999999999999999999999999999"));

            JTokenReader reader = new JTokenReader(s);

            Assert.AreEqual(true, reader.ReadAsBoolean());
        }
Exemplo n.º 4
0
        public void ReadAsBoolean_String_Success()
        {
            JValue s = JValue.CreateString("true");

            JTokenReader reader = new JTokenReader(s);

            Assert.AreEqual(true, reader.ReadAsBoolean());
        }
Exemplo n.º 5
0
        public void ReadAsBoolean_InvalidToken()
        {
            JArray a = new JArray
            {
                1, 2
            };

            JTokenReader reader = new JTokenReader(a);

            ExceptionAssert.Throws<JsonReaderException>(
                () => { reader.ReadAsBoolean(); },
                "Error reading boolean. Unexpected token: StartArray. Path ''.");
        }