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

            JTokenReader reader = new JTokenReader(n);

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

            JTokenReader reader = new JTokenReader(n);

            Assert.AreEqual(null, reader.ReadAsBoolean());
        }
Esempio 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());
        }
Esempio n. 4
0
        public void ReadAsBoolean_String_Success()
        {
            JValue s = JValue.CreateString("true");

            JTokenReader reader = new JTokenReader(s);

            Assert.AreEqual(true, reader.ReadAsBoolean());
        }
Esempio 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 ''.");
        }